summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-04-09 15:00:06 (UTC)
committer mickeyl <mickeyl>2004-04-09 15:00:06 (UTC)
commitfb2f09533c7476a266a877c351007c2706b2da0d (patch) (unidiff)
tree9742d4cb8fd07fd5530c3c29b5f049dcecd46ef4
parent39547839995c9f72ca9216ba5c2127246428ece8 (diff)
downloadopie-fb2f09533c7476a266a877c351007c2706b2da0d.zip
opie-fb2f09533c7476a266a877c351007c2706b2da0d.tar.gz
opie-fb2f09533c7476a266a877c351007c2706b2da0d.tar.bz2
- eliminate cylic dependency
- complete using opie debugging framework - sanitize #include order
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/interfaces/config.in4
-rw-r--r--noncore/settings/networksettings/networksettings.pro3
-rw-r--r--noncore/settings/networksettings/ppp/accounts.cpp2
-rw-r--r--noncore/settings/networksettings/ppp/authwidget.cpp16
-rw-r--r--noncore/settings/networksettings/ppp/config.in2
-rw-r--r--noncore/settings/networksettings/ppp/connect.cpp9
-rw-r--r--noncore/settings/networksettings/ppp/devices.cpp2
-rw-r--r--noncore/settings/networksettings/ppp/general.cpp2
-rw-r--r--noncore/settings/networksettings/ppp/interfaceinformationppp.cpp10
-rw-r--r--noncore/settings/networksettings/ppp/interfaceppp.cpp14
-rw-r--r--noncore/settings/networksettings/ppp/modem.cpp5
-rw-r--r--noncore/settings/networksettings/ppp/ppp.pro3
-rw-r--r--noncore/settings/networksettings/ppp/pppconfig.cpp14
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.cpp14
-rw-r--r--noncore/settings/networksettings/ppp/pppmodule.cpp2
-rw-r--r--noncore/settings/networksettings/wlan/config.in4
-rw-r--r--noncore/settings/networksettings/wlan/infoimp.cpp5
-rw-r--r--noncore/settings/networksettings/wlan/wextensions.cpp9
-rw-r--r--noncore/settings/networksettings/wlan/wlan.pro3
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp2.cpp26
-rw-r--r--noncore/settings/networksettings/wlan/wlanmodule.cpp2
21 files changed, 96 insertions, 55 deletions
diff --git a/noncore/settings/networksettings/interfaces/config.in b/noncore/settings/networksettings/interfaces/config.in
index d84cd24..2175800 100644
--- a/noncore/settings/networksettings/interfaces/config.in
+++ b/noncore/settings/networksettings/interfaces/config.in
@@ -1,4 +1,4 @@
1 config INTERFACES 1 config INTERFACES
2 boolean 2 boolean "Build interfaces for networksettings"
3 default "y" if NETWORKSETUP 3 default "y"
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE
diff --git a/noncore/settings/networksettings/networksettings.pro b/noncore/settings/networksettings/networksettings.pro
index 55d2291..9ad9be4 100644
--- a/noncore/settings/networksettings/networksettings.pro
+++ b/noncore/settings/networksettings/networksettings.pro
@@ -1,12 +1,11 @@
1CONFIG = qt warn_on quick-app 1CONFIG = qt warn_on quick-app
2HEADERS = mainwindowimp.h addconnectionimp.h defaultmodule.h module.h 2HEADERS = mainwindowimp.h addconnectionimp.h defaultmodule.h module.h
3SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp 3SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp
4INCLUDEPATH += $(OPIEDIR)/include interfaces/ . 4INCLUDEPATH += $(OPIEDIR)/include interfaces/ .
5DEPENDPATH += $(OPIEDIR)/include interfaces/ wlan/ ppp/ 5DEPENDPATH += $(OPIEDIR)/include interfaces/ wlan/ ppp/
6LIBS += -lqpe -L$(OPIEDIR)/plugins/networksettings -Linterfaces/ -linterfaces -lopiecore2 -lopieui2 6LIBS += -lqpe -L$(OPIEDIR)/plugins/networksettings -Linterfaces/ -linterfaces -lopiecore2 -lopieui2
7INTERFACES = mainwindow.ui addconnection.ui 7INTERFACES = mainwindow.ui addconnection.ui
8TARGET = networksettings 8TARGET = networksettings
9 9
10 10
11
12include ( $(OPIEDIR)/include.pro ) 11include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/settings/networksettings/ppp/accounts.cpp b/noncore/settings/networksettings/ppp/accounts.cpp
index aedc0b9..f05e7ac 100644
--- a/noncore/settings/networksettings/ppp/accounts.cpp
+++ b/noncore/settings/networksettings/ppp/accounts.cpp
@@ -1,349 +1,351 @@
1/* 1/*
2 * kPPP: A pppd front end for the KDE project 2 * kPPP: A pppd front end for the KDE project
3 * 3 *
4 * $Id$ 4 * $Id$
5 * 5 *
6 * Copyright (C) 1997 Bernd Johannes Wuebben 6 * Copyright (C) 1997 Bernd Johannes Wuebben
7 * wuebben@math.cornell.edu 7 * wuebben@math.cornell.edu
8 * 8 *
9 * based on EzPPP: 9 * based on EzPPP:
10 * Copyright (C) 1997 Jay Painter 10 * Copyright (C) 1997 Jay Painter
11 * 11 *
12 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Library General Public 13 * modify it under the terms of the GNU Library General Public
14 * License as published by the Free Software Foundation; either 14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version. 15 * version 2 of the License, or (at your option) any later version.
16 * 16 *
17 * This program is distributed in the hope that it will be useful, 17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details. 20 * Library General Public License for more details.
21 * 21 *
22 * You should have received a copy of the GNU Library General Public 22 * You should have received a copy of the GNU Library General Public
23 * License along with this program; if not, write to the Free 23 * License along with this program; if not, write to the Free
24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */ 25 */
26 26
27#include "accounts.h" 27#include "accounts.h"
28#include "authwidget.h" 28#include "authwidget.h"
29#include "pppdata.h" 29#include "pppdata.h"
30#include "edit.h" 30#include "edit.h"
31 31
32/* OPIE */ 32/* OPIE */
33#include <opie2/odebug.h>
33#include <qpe/qpeapplication.h> 34#include <qpe/qpeapplication.h>
35using namespace Opie::Core;
34 36
35/* QT */ 37/* QT */
36#include <qdir.h> 38#include <qdir.h>
37#include <qlayout.h> 39#include <qlayout.h>
38#include <qtabwidget.h> 40#include <qtabwidget.h>
39#include <qtabdialog.h> 41#include <qtabdialog.h>
40#include <qwhatsthis.h> 42#include <qwhatsthis.h>
41#include <qmessagebox.h> 43#include <qmessagebox.h>
42#include <qapplication.h> 44#include <qapplication.h>
43#include <qbuttongroup.h> 45#include <qbuttongroup.h>
44#include <qmessagebox.h> 46#include <qmessagebox.h>
45#include <qvgroupbox.h> 47#include <qvgroupbox.h>
46 48
47/* STD */ 49/* STD */
48#include <stdlib.h> 50#include <stdlib.h>
49 51
50void parseargs(char* buf, char** args); 52void parseargs(char* buf, char** args);
51 53
52 54
53AccountWidget::AccountWidget( PPPData *pd, QWidget *parent, const char *name, WFlags f ) 55AccountWidget::AccountWidget( PPPData *pd, QWidget *parent, const char *name, WFlags f )
54 : ChooserWidget( pd, parent, name, f ) 56 : ChooserWidget( pd, parent, name, f )
55{ 57{
56 58
57 QWhatsThis::add(edit_b, tr("Allows you to modify the selected account")); 59 QWhatsThis::add(edit_b, tr("Allows you to modify the selected account"));
58 QWhatsThis::add(new_b, tr("Create a new dialup connection\n" 60 QWhatsThis::add(new_b, tr("Create a new dialup connection\n"
59 "to the Internet")); 61 "to the Internet"));
60 QWhatsThis::add(copy_b, 62 QWhatsThis::add(copy_b,
61 tr("Makes a copy of the selected account. All\n" 63 tr("Makes a copy of the selected account. All\n"
62 "settings of the selected account are copied\n" 64 "settings of the selected account are copied\n"
63 "to a new account, that you can modify to fit your\n" 65 "to a new account, that you can modify to fit your\n"
64 "needs")); 66 "needs"));
65 QWhatsThis::add(delete_b, 67 QWhatsThis::add(delete_b,
66 tr("<p>Deletes the selected account\n\n" 68 tr("<p>Deletes the selected account\n\n"
67 "<font color=\"red\"><b>Use with care!</b></font>")); 69 "<font color=\"red\"><b>Use with care!</b></font>"));
68 70
69 71
70 72
71 copy_b->setEnabled( false ); //FIXME 73 copy_b->setEnabled( false ); //FIXME
72 // delete_b->setEnabled( false ); //FIXME 74 // delete_b->setEnabled( false ); //FIXME
73 75
74 listListbox->insertStringList(_pppdata->getAccountList()); 76 listListbox->insertStringList(_pppdata->getAccountList());
75 77
76 for (uint i = 0; i < listListbox->count(); i++) 78 for (uint i = 0; i < listListbox->count(); i++)
77 { 79 {
78 if ( listListbox->text(i) == _pppdata->accname() ) 80 if ( listListbox->text(i) == _pppdata->accname() )
79 listListbox->setCurrentItem( i ); 81 listListbox->setCurrentItem( i );
80 } 82 }
81} 83}
82 84
83 85
84 86
85void AccountWidget::slotListBoxSelect(int idx) 87void AccountWidget::slotListBoxSelect(int idx)
86{ 88{
87 bool ok = _pppdata->setAccount( listListbox->text(idx) ); 89 bool ok = _pppdata->setAccount( listListbox->text(idx) );
88 ok = (bool)(idx != -1); 90 ok = (bool)(idx != -1);
89 delete_b->setEnabled(ok); 91 delete_b->setEnabled(ok);
90 edit_b->setEnabled(ok); 92 edit_b->setEnabled(ok);
91 //FIXME copy_b->setEnabled(ok); 93 //FIXME copy_b->setEnabled(ok);
92} 94}
93 95
94void AccountWidget::edit() 96void AccountWidget::edit()
95{ 97{
96 _pppdata->setAccount(listListbox->text(listListbox->currentItem())); 98 _pppdata->setAccount(listListbox->text(listListbox->currentItem()));
97 99
98 int result = doTab(); 100 int result = doTab();
99 101
100 if(result == QDialog::Accepted) 102 if(result == QDialog::Accepted)
101 { 103 {
102 listListbox->changeItem(_pppdata->accname(),listListbox->currentItem()); 104 listListbox->changeItem(_pppdata->accname(),listListbox->currentItem());
103 // emit resetaccounts(); 105 // emit resetaccounts();
104 _pppdata->save(); 106 _pppdata->save();
105 } 107 }
106} 108}
107 109
108 110
109void AccountWidget::create() 111void AccountWidget::create()
110{ 112{
111 113
112 // if(listListbox->count() == MAX_ACCOUNTS) { 114 // if(listListbox->count() == MAX_ACCOUNTS) {
113 // QMessageBox::information(this, "sorry", 115 // QMessageBox::information(this, "sorry",
114 // tr("Maximum number of accounts reached.")); 116 // tr("Maximum number of accounts reached."));
115 // return; 117 // return;
116 // } 118 // }
117 119
118 int result; 120 int result;
119 if (_pppdata->newaccount() == -1) 121 if (_pppdata->newaccount() == -1)
120 { 122 {
121 odebug << "_pppdata->newaccount() == -1" << oendl; 123 odebug << "_pppdata->newaccount() == -1" << oendl;
122 return; 124 return;
123 } 125 }
124 result = doTab(); 126 result = doTab();
125 127
126 if(result == QDialog::Accepted) 128 if(result == QDialog::Accepted)
127 { 129 {
128 listListbox->insertItem(_pppdata->accname()); 130 listListbox->insertItem(_pppdata->accname());
129 listListbox->setSelected(listListbox->findItem(_pppdata->accname()),true); 131 listListbox->setSelected(listListbox->findItem(_pppdata->accname()),true);
130 132
131 _pppdata->save(); 133 _pppdata->save();
132 } 134 }
133 else 135 else
134 _pppdata->deleteAccount(); 136 _pppdata->deleteAccount();
135} 137}
136 138
137 139
138void AccountWidget::copy() 140void AccountWidget::copy()
139{ 141{
140 // if(listListbox->count() == MAX_ACCOUNTS) { 142 // if(listListbox->count() == MAX_ACCOUNTS) {
141 // QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached.")); 143 // QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached."));
142 // return; 144 // return;
143 // } 145 // }
144 146
145 if(listListbox->currentItem()<0) 147 if(listListbox->currentItem()<0)
146 { 148 {
147 QMessageBox::information(this, "sorry", tr("No account selected.")); 149 QMessageBox::information(this, "sorry", tr("No account selected."));
148 return; 150 return;
149 } 151 }
150 152
151 _pppdata->copyaccount(listListbox->currentText()); 153 _pppdata->copyaccount(listListbox->currentText());
152 154
153 listListbox->insertItem(_pppdata->accname()); 155 listListbox->insertItem(_pppdata->accname());
154 // emit resetaccounts(); 156 // emit resetaccounts();
155 _pppdata->save(); 157 _pppdata->save();
156} 158}
157 159
158 160
159void AccountWidget::remove() 161void AccountWidget::remove()
160{ 162{
161 163
162 QString s = tr("Are you sure you want to delete\nthe account \"%1\"?") 164 QString s = tr("Are you sure you want to delete\nthe account \"%1\"?")
163 .arg(listListbox->text(listListbox->currentItem())); 165 .arg(listListbox->text(listListbox->currentItem()));
164 166
165 if(QMessageBox::warning(this,tr("Confirm"),s, 167 if(QMessageBox::warning(this,tr("Confirm"),s,
166 QMessageBox::Yes,QMessageBox::No 168 QMessageBox::Yes,QMessageBox::No
167 ) != QMessageBox::Yes) 169 ) != QMessageBox::Yes)
168 return; 170 return;
169 171
170 if(_pppdata->deleteAccount(listListbox->text(listListbox->currentItem()))) 172 if(_pppdata->deleteAccount(listListbox->text(listListbox->currentItem())))
171 listListbox->removeItem(listListbox->currentItem()); 173 listListbox->removeItem(listListbox->currentItem());
172 174
173 175
174 // emit resetaccounts(); 176 // emit resetaccounts();
175 // _pppdata->save(); 177 // _pppdata->save();
176 178
177 179
178 slotListBoxSelect(listListbox->currentItem()); 180 slotListBoxSelect(listListbox->currentItem());
179 181
180} 182}
181 183
182 184
183int AccountWidget::doTab() 185int AccountWidget::doTab()
184{ 186{
185 QDialog *dlg = new QDialog( 0, "newAccount", true, Qt::WStyle_ContextHelp ); 187 QDialog *dlg = new QDialog( 0, "newAccount", true, Qt::WStyle_ContextHelp );
186 QVBoxLayout *layout = new QVBoxLayout( dlg ); 188 QVBoxLayout *layout = new QVBoxLayout( dlg );
187 layout->setSpacing( 0 ); 189 layout->setSpacing( 0 );
188 layout->setMargin( 1 ); 190 layout->setMargin( 1 );
189 191
190 QTabWidget *tabWindow = new QTabWidget( dlg, "tabWindow" ); 192 QTabWidget *tabWindow = new QTabWidget( dlg, "tabWindow" );
191 layout->addWidget( tabWindow ); 193 layout->addWidget( tabWindow );
192 194
193 bool isnewaccount; 195 bool isnewaccount;
194 196
195 if(_pppdata->accname().isEmpty()) 197 if(_pppdata->accname().isEmpty())
196 { 198 {
197 dlg->setCaption(tr("New Account")); 199 dlg->setCaption(tr("New Account"));
198 isnewaccount = true; 200 isnewaccount = true;
199 } 201 }
200 else 202 else
201 { 203 {
202 QString tit = tr("Edit Account: "); 204 QString tit = tr("Edit Account: ");
203 tit += _pppdata->accname(); 205 tit += _pppdata->accname();
204 dlg->setCaption(tit); 206 dlg->setCaption(tit);
205 isnewaccount = false; 207 isnewaccount = false;
206 } 208 }
207 209
208 // // DIAL WIDGET 210 // // DIAL WIDGET
209 dial_w = new DialWidget( _pppdata, tabWindow, isnewaccount, "Dial Setup"); 211 dial_w = new DialWidget( _pppdata, tabWindow, isnewaccount, "Dial Setup");
210 tabWindow->addTab( dial_w, tr("Dial") ); 212 tabWindow->addTab( dial_w, tr("Dial") );
211 213
212 // // AUTH WIDGET 214 // // AUTH WIDGET
213 auth_w = new AuthWidget( _pppdata, tabWindow, isnewaccount, tr("Edit Login Script")); 215 auth_w = new AuthWidget( _pppdata, tabWindow, isnewaccount, tr("Edit Login Script"));
214 tabWindow->addTab( auth_w, tr("Authentication") ); 216 tabWindow->addTab( auth_w, tr("Authentication") );
215 217
216 // // IP WIDGET 218 // // IP WIDGET
217 ip_w = new IPWidget( _pppdata, tabWindow, isnewaccount, tr("IP Setup")); 219 ip_w = new IPWidget( _pppdata, tabWindow, isnewaccount, tr("IP Setup"));
218 tabWindow->addTab( ip_w, tr("IP") ); 220 tabWindow->addTab( ip_w, tr("IP") );
219 221
220 // // GATEWAY WIDGET 222 // // GATEWAY WIDGET
221 gateway_w = new GatewayWidget( _pppdata, tabWindow, isnewaccount, tr("Gateway Setup")); 223 gateway_w = new GatewayWidget( _pppdata, tabWindow, isnewaccount, tr("Gateway Setup"));
222 tabWindow->addTab( gateway_w, tr("Gateway") ); 224 tabWindow->addTab( gateway_w, tr("Gateway") );
223 225
224 // // DNS WIDGET 226 // // DNS WIDGET
225 dns_w = new DNSWidget( _pppdata, tabWindow, isnewaccount, tr("DNS Servers") ); 227 dns_w = new DNSWidget( _pppdata, tabWindow, isnewaccount, tr("DNS Servers") );
226 tabWindow->addTab( dns_w, tr("DNS") ); 228 tabWindow->addTab( dns_w, tr("DNS") );
227 229
228 // // EXECUTE WIDGET 230 // // EXECUTE WIDGET
229 ExecWidget *exec_w = new ExecWidget( _pppdata, tabWindow, isnewaccount, tr("Execute Programs")); 231 ExecWidget *exec_w = new ExecWidget( _pppdata, tabWindow, isnewaccount, tr("Execute Programs"));
230 tabWindow->addTab( exec_w, tr("Execute") ); 232 tabWindow->addTab( exec_w, tr("Execute") );
231 233
232 int result = 0; 234 int result = 0;
233 bool ok = false; 235 bool ok = false;
234 236
235 while (!ok) 237 while (!ok)
236 { 238 {
237 result = QPEApplication::execDialog( dlg ); 239 result = QPEApplication::execDialog( dlg );
238 ok = true; 240 ok = true;
239 241
240 if(result == QDialog::Accepted) 242 if(result == QDialog::Accepted)
241 { 243 {
242 if (!auth_w->check()) 244 if (!auth_w->check())
243 { 245 {
244 ok = false; 246 ok = false;
245 } 247 }
246 else if(!dial_w->save()) 248 else if(!dial_w->save())
247 { 249 {
248 QMessageBox::critical(this, "error", tr( "You must enter a unique account name")); 250 QMessageBox::critical(this, "error", tr( "You must enter a unique account name"));
249 ok = false; 251 ok = false;
250 } 252 }
251 else 253 else
252 { 254 {
253 ip_w->save(); 255 ip_w->save();
254 dns_w->save(); 256 dns_w->save();
255 gateway_w->save(); 257 gateway_w->save();
256 auth_w->save(); 258 auth_w->save();
257 exec_w->save(); 259 exec_w->save();
258 } 260 }
259 } 261 }
260 } 262 }
261 263
262 delete dlg; 264 delete dlg;
263 265
264 return result; 266 return result;
265} 267}
266 268
267 269
268// QString AccountWidget::prettyPrintVolume(unsigned int n) { 270// QString AccountWidget::prettyPrintVolume(unsigned int n) {
269// int idx = 0; 271// int idx = 0;
270// const QString quant[] = {tr("Byte"), tr("KB"), 272// const QString quant[] = {tr("Byte"), tr("KB"),
271 // tr("MB"), tr("GB"), QString::null}; 273 // tr("MB"), tr("GB"), QString::null};
272 274
273// float n1 = n; 275// float n1 = n;
274// while(n >= 1024 && quant[idx] != QString::null) { 276// while(n >= 1024 && quant[idx] != QString::null) {
275// idx++; 277// idx++;
276// n /= 1024; 278// n /= 1024;
277// } 279// }
278 280
279// int i = idx; 281// int i = idx;
280// while(i--) 282// while(i--)
281// n1 = n1 / 1024.0; 283// n1 = n1 / 1024.0;
282 284
283// QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 ); 285// QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 );
284// s += " " + quant[idx]; 286// s += " " + quant[idx];
285// return s; 287// return s;
286// } 288// }
287 289
288 290
289///////////////////////////////////////////////////////////////////////////// 291/////////////////////////////////////////////////////////////////////////////
290// 292//
291// Queries the user what to reset: costs, volume or both 293// Queries the user what to reset: costs, volume or both
292// 294//
293///////////////////////////////////////////////////////////////////////////// 295/////////////////////////////////////////////////////////////////////////////
294// QueryReset::QueryReset(QWidget *parent) : QDialog(parent, 0, true) { 296// QueryReset::QueryReset(QWidget *parent) : QDialog(parent, 0, true) {
295// // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); 297// // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
296// setCaption(tr("Reset Accounting")); 298// setCaption(tr("Reset Accounting"));
297 299
298// QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); 300// QVBoxLayout *tl = new QVBoxLayout(this, 10, 10);
299// QVGroupBox *f = new QVGroupBox(tr("What to Reset"), this); 301// QVGroupBox *f = new QVGroupBox(tr("What to Reset"), this);
300 302
301// QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10); 303// QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10);
302// // costs = new QCheckBox(tr("Reset the accumulated phone costs"), f); 304// // costs = new QCheckBox(tr("Reset the accumulated phone costs"), f);
303// // costs->setChecked(true); 305// // costs->setChecked(true);
304// // l1->addWidget(costs); 306// // l1->addWidget(costs);
305// // QWhatsThis::add(costs, tr("Check this to set the phone costs\n" 307// // QWhatsThis::add(costs, tr("Check this to set the phone costs\n"
306 // // "to zero. Typically you'll want to\n" 308 // // "to zero. Typically you'll want to\n"
307 // // "do this once a month.")); 309 // // "do this once a month."));
308 310
309// // volume = new QCheckBox(tr("Reset volume accounting"), f); 311// // volume = new QCheckBox(tr("Reset volume accounting"), f);
310// // volume->setChecked(true); 312// // volume->setChecked(true);
311// // l1->addWidget(volume); 313// // l1->addWidget(volume);
312// // QWhatsThis::add(volume, tr("Check this to set the volume accounting\n" 314// // QWhatsThis::add(volume, tr("Check this to set the volume accounting\n"
313 // // "to zero. Typically you'll want to do this\n" 315 // // "to zero. Typically you'll want to do this\n"
314 // // "once a month.")); 316 // // "once a month."));
315 317
316// l1->activate(); 318// l1->activate();
317 319
318// // this activates the f-layout and sets minimumSize() 320// // this activates the f-layout and sets minimumSize()
319// f->show(); 321// f->show();
320 322
321// tl->addWidget(f); 323// tl->addWidget(f);
322 324
323// QButtonGroup *bbox = new QButtonGroup(this); 325// QButtonGroup *bbox = new QButtonGroup(this);
324// // bbox->addStretch(1); 326// // bbox->addStretch(1);
325// QPushButton *ok = new QPushButton( bbox, tr("OK") ); 327// QPushButton *ok = new QPushButton( bbox, tr("OK") );
326// bbox->insert(ok); 328// bbox->insert(ok);
327// ok->setDefault(true); 329// ok->setDefault(true);
328// QPushButton *cancel = new QPushButton( bbox, tr("Cancel") ); 330// QPushButton *cancel = new QPushButton( bbox, tr("Cancel") );
329// bbox->insert(cancel); 331// bbox->insert(cancel);
330 332
331// connect(ok, SIGNAL(clicked()), 333// connect(ok, SIGNAL(clicked()),
332 // this, SLOT(accepted())); 334 // this, SLOT(accepted()));
333// connect(cancel, SIGNAL(clicked()), 335// connect(cancel, SIGNAL(clicked()),
334 // this, SLOT(reject())); 336 // this, SLOT(reject()));
335 337
336// bbox->layout(); 338// bbox->layout();
337// tl->addWidget(bbox); 339// tl->addWidget(bbox);
338 340
339// } 341// }
340 342
341 343
342// void QueryReset::accepted() { 344// void QueryReset::accepted() {
343// int result = costs->isChecked() ? COSTS : 0; 345// int result = costs->isChecked() ? COSTS : 0;
344// result += volume->isChecked() ? VOLUME : 0; 346// result += volume->isChecked() ? VOLUME : 0;
345 347
346// done(result); 348// done(result);
347// } 349// }
348 350
349 351
diff --git a/noncore/settings/networksettings/ppp/authwidget.cpp b/noncore/settings/networksettings/ppp/authwidget.cpp
index f3d842f..c94c3bc 100644
--- a/noncore/settings/networksettings/ppp/authwidget.cpp
+++ b/noncore/settings/networksettings/ppp/authwidget.cpp
@@ -1,197 +1,201 @@
1
2#include <qlayout.h>
3#include <qmessagebox.h>
4#include <qtoolbutton.h>
5#include <qwhatsthis.h>
6
7#include "auth.h" 1#include "auth.h"
8#include "authwidget.h" 2#include "authwidget.h"
9#include "edit.h" 3#include "edit.h"
10#include "pppdata.h" 4#include "pppdata.h"
11 5
6/* OPIE */
7#include <opie2/odebug.h>
8using namespace Opie::Core;
9
10/* QT */
11#include <qlayout.h>
12#include <qmessagebox.h>
13#include <qtoolbutton.h>
14#include <qwhatsthis.h>
12 15
16/* XPM */
13static const char* const image0_data[] = { 17static const char* const image0_data[] = {
14"16 16 2 1", 18"16 16 2 1",
15". c None", 19". c None",
16"# c #000000", 20"# c #000000",
17"................", 21"................",
18"...#...###...##.", 22"...#...###...##.",
19"..#.#..#..#.##..", 23"..#.#..#..#.##..",
20"..###..###.##...", 24"..###..###.##...",
21".#...#.#..##....", 25".#...#.#..##....",
22".#...#.#.##.....", 26".#...#.#.##.....",
23"........##.#..#.", 27"........##.#..#.",
24"..##...##...##..", 28"..##...##...##..",
25".#..#.###...##..", 29".#..#.###...##..",
26".#...##..#.#..#.", 30".#...##..#.#..#.",
27".#..##..........", 31".#..##..........",
28".#.##.#..#.#..#.", 32".#.##.#..#.#..#.",
29"..##...##...##..", 33"..##...##...##..",
30".##....##...##..", 34".##....##...##..",
31".#....#..#.#..#.", 35".#....#..#.#..#.",
32"................"}; 36"................"};
33 37
34 38
35AuthWidget::AuthWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) 39AuthWidget::AuthWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const char *name )
36 : QWidget( parent, name), 40 : QWidget( parent, name),
37 scriptWidget(0), 41 scriptWidget(0),
38 _pppdata(pd), 42 _pppdata(pd),
39 isNewAccount(isnewaccount) 43 isNewAccount(isnewaccount)
40{ 44{
41 layout = new QGridLayout(this); 45 layout = new QGridLayout(this);
42 46
43 auth_l = new QLabel(tr("Authentication: "), this); 47 auth_l = new QLabel(tr("Authentication: "), this);
44 layout->addWidget(auth_l, 0, 0); 48 layout->addWidget(auth_l, 0, 0);
45 49
46 auth = new QComboBox(this); 50 auth = new QComboBox(this);
47 auth->insertItem(tr("Script-based")); 51 auth->insertItem(tr("Script-based"));
48 auth->insertItem(tr("PAP")); 52 auth->insertItem(tr("PAP"));
49 auth->insertItem(tr("Terminal-based")); 53 auth->insertItem(tr("Terminal-based"));
50 auth->insertItem(tr("CHAP")); 54 auth->insertItem(tr("CHAP"));
51 auth->insertItem(tr("PAP/CHAP")); 55 auth->insertItem(tr("PAP/CHAP"));
52 layout->addWidget(auth, 0, 1); 56 layout->addWidget(auth, 0, 1);
53 57
54 connect( auth, SIGNAL(activated(const QString&)), 58 connect( auth, SIGNAL(activated(const QString&)),
55 SLOT(authChanged(const QString&))); 59 SLOT(authChanged(const QString&)));
56 60
57 QString tmp = tr("<p>Specifies the method used to identify yourself to\n" 61 QString tmp = tr("<p>Specifies the method used to identify yourself to\n"
58 "the PPP server. Most universities still use\n" 62 "the PPP server. Most universities still use\n"
59 "<b>Terminal</b>- or <b>Script</b>-based authentication,\n" 63 "<b>Terminal</b>- or <b>Script</b>-based authentication,\n"
60 "while most ISP use <b>PAP</b> and/or <b>CHAP</b>. If\n" 64 "while most ISP use <b>PAP</b> and/or <b>CHAP</b>. If\n"
61 "unsure, contact your ISP.\n" 65 "unsure, contact your ISP.\n"
62 "\n" 66 "\n"
63 "If you can choose between PAP and CHAP,\n" 67 "If you can choose between PAP and CHAP,\n"
64 "choose CHAP, because it's much safer. If you don't know\n" 68 "choose CHAP, because it's much safer. If you don't know\n"
65 "whether PAP or CHAP is right, choose PAP/CHAP."); 69 "whether PAP or CHAP is right, choose PAP/CHAP.");
66 70
67 QWhatsThis::add(auth_l,tmp); 71 QWhatsThis::add(auth_l,tmp);
68 QWhatsThis::add(auth,tmp); 72 QWhatsThis::add(auth,tmp);
69 73
70 user_l = new QLabel( tr("Username: "), this); 74 user_l = new QLabel( tr("Username: "), this);
71 layout->addWidget( user_l, 1, 0 ); 75 layout->addWidget( user_l, 1, 0 );
72 userName = new QLineEdit( this, "usernameEdit" ); 76 userName = new QLineEdit( this, "usernameEdit" );
73 layout->addWidget( userName, 1, 1 ); 77 layout->addWidget( userName, 1, 1 );
74 tmp = tr("Enter your username here..."); 78 tmp = tr("Enter your username here...");
75 QWhatsThis::add( user_l, tmp ); 79 QWhatsThis::add( user_l, tmp );
76 QWhatsThis::add( userName, tmp ); 80 QWhatsThis::add( userName, tmp );
77 81
78 pw_l = new QLabel( tr("Password: "), this); 82 pw_l = new QLabel( tr("Password: "), this);
79 layout->addWidget( pw_l, 2, 0 ); 83 layout->addWidget( pw_l, 2, 0 );
80 passWord = new QLineEdit( this, "pw" ); 84 passWord = new QLineEdit( this, "pw" );
81 passWord->setAutoMask( true ); 85 passWord->setAutoMask( true );
82 passWord->setEchoMode( QLineEdit::Password ); 86 passWord->setEchoMode( QLineEdit::Password );
83 layout->addWidget( passWord, 2, 1 ); 87 layout->addWidget( passWord, 2, 1 );
84 hidePw = new QToolButton( this ); 88 hidePw = new QToolButton( this );
85 hidePw->setPixmap( QPixmap( ( const char** ) image0_data ) ); 89 hidePw->setPixmap( QPixmap( ( const char** ) image0_data ) );
86 hidePw->setToggleButton( true ); 90 hidePw->setToggleButton( true );
87 layout->addWidget( hidePw, 2, 2 ); 91 layout->addWidget( hidePw, 2, 2 );
88 92
89 connect(hidePw, SIGNAL(toggled(bool)), SLOT(toggleEchoMode(bool))); 93 connect(hidePw, SIGNAL(toggled(bool)), SLOT(toggleEchoMode(bool)));
90 94
91 tmp = tr("Enter your password here"); 95 tmp = tr("Enter your password here");
92 QWhatsThis::add( pw_l, tmp ); 96 QWhatsThis::add( pw_l, tmp );
93 QWhatsThis::add( passWord, tmp ); 97 QWhatsThis::add( passWord, tmp );
94 98
95 store_password = new QCheckBox(tr("Store password"), this); 99 store_password = new QCheckBox(tr("Store password"), this);
96 layout->addMultiCellWidget(store_password, 3, 3, 0, 1, AlignRight); 100 layout->addMultiCellWidget(store_password, 3, 3, 0, 1, AlignRight);
97 QWhatsThis::add(store_password, 101 QWhatsThis::add(store_password,
98 tr("<p>When this is turned on, your ISP password\n" 102 tr("<p>When this is turned on, your ISP password\n"
99 "will be saved in <i>kppp</i>'s config file, so\n" 103 "will be saved in <i>kppp</i>'s config file, so\n"
100 "you do not need to type it in every time.\n" 104 "you do not need to type it in every time.\n"
101 "\n" 105 "\n"
102 "<b><font color=\"red\">Warning:</font> your password will be stored as\n" 106 "<b><font color=\"red\">Warning:</font> your password will be stored as\n"
103 "plain text in the config file, which is\n" 107 "plain text in the config file, which is\n"
104 "readable only to you. Make sure nobody\n" 108 "readable only to you. Make sure nobody\n"
105 "gains access to this file!")); 109 "gains access to this file!"));
106 110
107 if (isNewAccount){ 111 if (isNewAccount){
108 // select PAP/CHAP as default 112 // select PAP/CHAP as default
109 auth->setCurrentItem(AUTH_PAPCHAP); 113 auth->setCurrentItem(AUTH_PAPCHAP);
110 store_password->setChecked(true); 114 store_password->setChecked(true);
111 }else{ 115 }else{
112 auth->setCurrentItem(_pppdata->authMethod()); 116 auth->setCurrentItem(_pppdata->authMethod());
113 authChanged( auth->currentText() ); 117 authChanged( auth->currentText() );
114 userName->setText( _pppdata->storedUsername() ); 118 userName->setText( _pppdata->storedUsername() );
115 store_password->setChecked(_pppdata->storePassword()); 119 store_password->setChecked(_pppdata->storePassword());
116 if (store_password->isChecked()) 120 if (store_password->isChecked())
117 passWord->setText( _pppdata->storedPassword() ); 121 passWord->setText( _pppdata->storedPassword() );
118 } 122 }
119} 123}
120 124
121bool AuthWidget::check() 125bool AuthWidget::check()
122{ 126{
123 bool ret = true; 127 bool ret = true;
124 if (scriptWidget){ 128 if (scriptWidget){
125 if (!scriptWidget->check()){ 129 if (!scriptWidget->check()){
126 QMessageBox::critical(this, tr("error"), tr("<qt>Login script has unbalanced loop Start/End<qt>")); 130 QMessageBox::critical(this, tr("error"), tr("<qt>Login script has unbalanced loop Start/End<qt>"));
127 ret = false; 131 ret = false;
128 } 132 }
129 } 133 }
130 return ret; 134 return ret;
131} 135}
132 136
133void AuthWidget::save() 137void AuthWidget::save()
134{ 138{
135 _pppdata->setAuthMethod(auth->currentItem()); 139 _pppdata->setAuthMethod(auth->currentItem());
136 if (scriptWidget) scriptWidget->save(); 140 if (scriptWidget) scriptWidget->save();
137 _pppdata->setStoredUsername( userName->text() ); 141 _pppdata->setStoredUsername( userName->text() );
138 _pppdata->setStorePassword(store_password->isChecked()); 142 _pppdata->setStorePassword(store_password->isChecked());
139 if (store_password->isChecked()) 143 if (store_password->isChecked())
140 _pppdata->setStoredPassword( passWord->text() ); 144 _pppdata->setStoredPassword( passWord->text() );
141} 145}
142 146
143void AuthWidget::authChanged( const QString &authStr ) 147void AuthWidget::authChanged( const QString &authStr )
144{ 148{
145 odebug << "AuthWidget::authChanged( " << authStr.latin1() << " )" << oendl; 149 odebug << "AuthWidget::authChanged( " << authStr.latin1() << " )" << oendl;
146 if ( authStr.contains( tr("Script-based") ) ){ 150 if ( authStr.contains( tr("Script-based") ) ){
147 showUsernamePassword( false ); 151 showUsernamePassword( false );
148 showScriptWindow( true ); 152 showScriptWindow( true );
149 } else if ( authStr.contains( tr("PAP") ) || 153 } else if ( authStr.contains( tr("PAP") ) ||
150 authStr.contains( tr("CHAP") ) ){ 154 authStr.contains( tr("CHAP") ) ){
151 showUsernamePassword( true ); 155 showUsernamePassword( true );
152 showScriptWindow( false ); 156 showScriptWindow( false );
153 } else { 157 } else {
154 odebug << "do not really know how to handle" << oendl; 158 odebug << "do not really know how to handle" << oendl;
155 showUsernamePassword( false ); 159 showUsernamePassword( false );
156 showScriptWindow( false ); 160 showScriptWindow( false );
157 } 161 }
158} 162}
159 163
160 164
161void AuthWidget::showUsernamePassword( bool show ) 165void AuthWidget::showUsernamePassword( bool show )
162{ 166{
163 if (show){ 167 if (show){
164 user_l->show(); 168 user_l->show();
165 userName->show(); 169 userName->show();
166 pw_l->show(); 170 pw_l->show();
167 passWord->show(); 171 passWord->show();
168 store_password->show(); 172 store_password->show();
169 hidePw->show(); 173 hidePw->show();
170 }else{//!show 174 }else{//!show
171 user_l->hide(); 175 user_l->hide();
172 userName->hide(); 176 userName->hide();
173 pw_l->hide(); 177 pw_l->hide();
174 passWord->hide(); 178 passWord->hide();
175 store_password->hide(); 179 store_password->hide();
176 hidePw->hide(); 180 hidePw->hide();
177 } 181 }
178} 182}
179 183
180void AuthWidget::showScriptWindow( bool show ) 184void AuthWidget::showScriptWindow( bool show )
181{ 185{
182 if (show){ 186 if (show){
183 if (!scriptWidget){ 187 if (!scriptWidget){
184 scriptWidget = new ScriptWidget( _pppdata, this, isNewAccount, "scriptWid"); 188 scriptWidget = new ScriptWidget( _pppdata, this, isNewAccount, "scriptWid");
185 layout->addMultiCellWidget( scriptWidget, 1, 4, 0, 1 ); 189 layout->addMultiCellWidget( scriptWidget, 1, 4, 0, 1 );
186 } 190 }
187 scriptWidget->show(); 191 scriptWidget->show();
188 }else{ // !show 192 }else{ // !show
189 if (scriptWidget) scriptWidget->hide(); 193 if (scriptWidget) scriptWidget->hide();
190 } 194 }
191} 195}
192 196
193void AuthWidget::toggleEchoMode( bool t ) 197void AuthWidget::toggleEchoMode( bool t )
194{ 198{
195 passWord->setEchoMode( t ? QLineEdit::Normal : QLineEdit::Password ); 199 passWord->setEchoMode( t ? QLineEdit::Normal : QLineEdit::Password );
196} 200}
197 201
diff --git a/noncore/settings/networksettings/ppp/config.in b/noncore/settings/networksettings/ppp/config.in
index 0b71434..570ebfe 100644
--- a/noncore/settings/networksettings/ppp/config.in
+++ b/noncore/settings/networksettings/ppp/config.in
@@ -1,4 +1,4 @@
1 config PPP 1 config PPP
2 boolean "opie-networksettingsplugin-kppp (PPP module)" 2 boolean "opie-networksettingsplugin-kppp (PPP module)"
3 default "n" if NETWORKSETUP 3 default "y"
4 depends ( LIBQPE || LIBQPE-X11 ) && NETWORKSETUP && NETWORKSETUP-CORE && INTERFACES 4 depends ( LIBQPE || LIBQPE-X11 ) && NETWORKSETUP && NETWORKSETUP-CORE && INTERFACES
diff --git a/noncore/settings/networksettings/ppp/connect.cpp b/noncore/settings/networksettings/ppp/connect.cpp
index b75410c..24d33f4 100644
--- a/noncore/settings/networksettings/ppp/connect.cpp
+++ b/noncore/settings/networksettings/ppp/connect.cpp
@@ -1,1466 +1,1467 @@
1/* 1/*
2 * kPPP: A pppd front end for the KDE project 2 * kPPP: A pppd front end for the KDE project
3 * 3 *
4 * 4 *
5 * Copyright (C) 1997 Bernd Johannes Wuebben 5 * Copyright (C) 1997 Bernd Johannes Wuebben
6 * wuebben@math.cornell.edu 6 * wuebben@math.cornell.edu
7 * Copyright (C) 1998-2001 Harri Porten <porten@kde.org> 7 * Copyright (C) 1998-2001 Harri Porten <porten@kde.org>
8 * 8 *
9 * based on EzPPP: 9 * based on EzPPP:
10 * Copyright (C) 1997 Jay Painter 10 * Copyright (C) 1997 Jay Painter
11 * 11 *
12 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Library General Public 13 * modify it under the terms of the GNU Library General Public
14 * License as published by the Free Software Foundation; either 14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version. 15 * version 2 of the License, or (at your option) any later version.
16 * 16 *
17 * This program is distributed in the hope that it will be useful, 17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details. 20 * Library General Public License for more details.
21 * 21 *
22 * You should have received a copy of the GNU Library General Public 22 * You should have received a copy of the GNU Library General Public
23 * License along with this program; if not, write to the Free 23 * License along with this program; if not, write to the Free
24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */ 25 */
26 26
27//#include <config.h> 27/* OPIE */
28#include <opie2/odebug.h>
29using namespace Opie::Core;
28 30
31/* QT */
29#include <qlayout.h> 32#include <qlayout.h>
30#include <qregexp.h> 33#include <qregexp.h>
31
32#include <qapplication.h> 34#include <qapplication.h>
33//#include <kdebug.h>
34//#include <klocale.h>
35#include <qmessagebox.h> 35#include <qmessagebox.h>
36#include <qpushbutton.h> 36#include <qpushbutton.h>
37 37
38/* STD */
38#include <unistd.h> 39#include <unistd.h>
39#include <stdlib.h> 40#include <stdlib.h>
40#include <string.h> 41#include <string.h>
41#include <fcntl.h> 42#include <fcntl.h>
42#include <netdb.h> 43#include <netdb.h>
43#include <sys/types.h> 44#include <sys/types.h>
44#include <sys/socket.h> 45#include <sys/socket.h>
45#include <arpa/inet.h> 46#include <arpa/inet.h>
46#include <netinet/in.h> 47#include <netinet/in.h>
47#include <sys/ioctl.h> 48#include <sys/ioctl.h>
48#include <assert.h> 49#include <assert.h>
49 50
50#ifdef _XPG4_2 51#ifdef _XPG4_2
51 #define __xnet_connectconnect 52 #define __xnet_connectconnect
52#endif 53#endif
53 54
54#include <errno.h> 55#include <errno.h>
55 56
56#ifdef HAVE_SYS_PARAM_H 57#ifdef HAVE_SYS_PARAM_H
57#include <sys/param.h> 58#include <sys/param.h>
58#endif 59#endif
59 60
60#ifdef __linux__ 61#ifdef __linux__
61#include "runtests.h" 62#include "runtests.h"
62#endif 63#endif
63 64
64#include "auth.h" 65#include "auth.h"
65#include "connect.h" 66#include "connect.h"
66//#include "docking.h" 67//#include "docking.h"
67#include "interfaceppp.h" 68#include "interfaceppp.h"
68#include "modem.h" 69#include "modem.h"
69#include "kpppconfig.h" 70#include "kpppconfig.h"
70#include "pppdata.h" 71#include "pppdata.h"
71#include "kpppwidget.h" 72#include "kpppwidget.h"
72//#include "requester.h" 73//#include "requester.h"
73//#include "utils.h" 74//#include "utils.h"
74#define execute_command system 75#define execute_command system
75 76
76QString old_hostname; 77QString old_hostname;
77bool modified_hostname; 78bool modified_hostname;
78 79
79 80
80ConnectWidget::ConnectWidget(InterfacePPP *ifp, QWidget *parent, const char *name) 81ConnectWidget::ConnectWidget(InterfacePPP *ifp, QWidget *parent, const char *name)
81 : QWidget(parent, name), 82 : QWidget(parent, name),
82 myreadbuffer(""), 83 myreadbuffer(""),
83 main_timer_ID(0), 84 main_timer_ID(0),
84 vmain(0), 85 vmain(0),
85 substate(-1), 86 substate(-1),
86 scriptindex(0), 87 scriptindex(0),
87 loopnest(0), 88 loopnest(0),
88 loopend(false), 89 loopend(false),
89 semaphore(false), 90 semaphore(false),
90 expecting(false), 91 expecting(false),
91 readbuffer(""), 92 readbuffer(""),
92 scanvar(""), 93 scanvar(""),
93 scanning(false), 94 scanning(false),
94 pausing(false), 95 pausing(false),
95 dialnumber(0), 96 dialnumber(0),
96 _ifaceppp(ifp) 97 _ifaceppp(ifp)
97{ 98{
98 modified_hostname = false; 99 modified_hostname = false;
99 100
100 QVBoxLayout *tl = new QVBoxLayout(this, 8, 10); 101 QVBoxLayout *tl = new QVBoxLayout(this, 8, 10);
101 QString tit = QObject::tr("Connecting to: "); 102 QString tit = QObject::tr("Connecting to: ");
102 setCaption(tit); 103 setCaption(tit);
103 104
104 QHBoxLayout *l0 = new QHBoxLayout(10); 105 QHBoxLayout *l0 = new QHBoxLayout(10);
105 tl->addLayout(l0); 106 tl->addLayout(l0);
106 l0->addSpacing(10); 107 l0->addSpacing(10);
107 messg = new QLabel(this, "messg"); 108 messg = new QLabel(this, "messg");
108 messg->setFrameStyle(QFrame::Panel|QFrame::Sunken); 109 messg->setFrameStyle(QFrame::Panel|QFrame::Sunken);
109 messg->setAlignment(AlignCenter); 110 messg->setAlignment(AlignCenter);
110 messg->setText(QObject::tr("Unable to create modem lock file.")); 111 messg->setText(QObject::tr("Unable to create modem lock file."));
111 messg->setMinimumHeight(messg->sizeHint().height() + 5); 112 messg->setMinimumHeight(messg->sizeHint().height() + 5);
112// int messw = (messg->sizeHint().width() * 12) / 10; 113// int messw = (messg->sizeHint().width() * 12) / 10;
113// messw = QMAX(messw,280); 114// messw = QMAX(messw,280);
114// messg->setMinimumWidth(messw); 115// messg->setMinimumWidth(messw);
115 if (_ifaceppp->getStatus()) 116 if (_ifaceppp->getStatus())
116 messg->setText(QObject::tr("Online")); 117 messg->setText(QObject::tr("Online"));
117 else 118 else
118 messg->setText(QObject::tr("Offline")); 119 messg->setText(QObject::tr("Offline"));
119 l0->addSpacing(10); 120 l0->addSpacing(10);
120 l0->addWidget(messg); 121 l0->addWidget(messg);
121 l0->addSpacing(10); 122 l0->addSpacing(10);
122 123
123 QHBoxLayout *l1 = new QHBoxLayout(10); 124 QHBoxLayout *l1 = new QHBoxLayout(10);
124 tl->addLayout(l1); 125 tl->addLayout(l1);
125 l1->addStretch(1); 126 l1->addStretch(1);
126 127
127 debug = new QPushButton(QObject::tr("Log"), this); 128 debug = new QPushButton(QObject::tr("Log"), this);
128 debug->setToggleButton(true); 129 debug->setToggleButton(true);
129 debug->setEnabled( false ); // FIXME: disable the log button 130 debug->setEnabled( false ); // FIXME: disable the log button
130 connect(debug, SIGNAL(clicked()), SIGNAL(toggleDebugWindow())); 131 connect(debug, SIGNAL(clicked()), SIGNAL(toggleDebugWindow()));
131 132
132 cancel = new QPushButton(QObject::tr("Cancel"), this); 133 cancel = new QPushButton(QObject::tr("Cancel"), this);
133 cancel->setFocus(); 134 cancel->setFocus();
134 connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton())); 135 connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton()));
135 136
136// int maxw = QMAX(cancel->sizeHint().width(), 137// int maxw = QMAX(cancel->sizeHint().width(),
137 // debug->sizeHint().width()); 138 // debug->sizeHint().width());
138// maxw = QMAX(maxw,65); 139// maxw = QMAX(maxw,65);
139// debug->setFixedWidth(maxw); 140// debug->setFixedWidth(maxw);
140// cancel->setFixedWidth(maxw); 141// cancel->setFixedWidth(maxw);
141 l1->addWidget(debug); 142 l1->addWidget(debug);
142 l1->addWidget(cancel); 143 l1->addWidget(cancel);
143 144
144// setFixedSize(sizeHint()); 145// setFixedSize(sizeHint());
145 146
146 pausetimer = new QTimer(this); 147 pausetimer = new QTimer(this);
147 connect(pausetimer, SIGNAL(timeout()), SLOT(pause())); 148 connect(pausetimer, SIGNAL(timeout()), SLOT(pause()));
148 149
149 qApp->processEvents(); 150 qApp->processEvents();
150 151
151 timeout_timer = new QTimer(this); 152 timeout_timer = new QTimer(this);
152 connect(timeout_timer, SIGNAL(timeout()), SLOT(script_timed_out())); 153 connect(timeout_timer, SIGNAL(timeout()), SLOT(script_timed_out()));
153 154
154 inittimer = new QTimer(this); 155 inittimer = new QTimer(this);
155 connect(inittimer, SIGNAL(timeout()), SLOT(init())); 156 connect(inittimer, SIGNAL(timeout()), SLOT(init()));
156 157
157 if_timeout_timer = new QTimer(this); 158 if_timeout_timer = new QTimer(this);
158 connect(if_timeout_timer, SIGNAL(timeout()), SLOT(if_waiting_timed_out())); 159 connect(if_timeout_timer, SIGNAL(timeout()), SLOT(if_waiting_timed_out()));
159 160
160 connect(this,SIGNAL(if_waiting_signal()),this,SLOT(if_waiting_slot())); 161 connect(this,SIGNAL(if_waiting_signal()),this,SLOT(if_waiting_slot()));
161 162
162 prompt = new PWEntry( this, "pw" ); 163 prompt = new PWEntry( this, "pw" );
163 if_timer = new QTimer(this); 164 if_timer = new QTimer(this);
164 connect(if_timer,SIGNAL(timeout()), SLOT(if_waiting_slot())); 165 connect(if_timer,SIGNAL(timeout()), SLOT(if_waiting_slot()));
165} 166}
166 167
167 168
168ConnectWidget::~ConnectWidget() { 169ConnectWidget::~ConnectWidget() {
169} 170}
170 171
171 172
172void ConnectWidget::preinit() { 173void ConnectWidget::preinit() {
173 // this is all just to keep the GUI nice and snappy .... 174 // this is all just to keep the GUI nice and snappy ....
174 // you have to see to believe ... 175 // you have to see to believe ...
175 messg->setText(QObject::tr("Looking for modem...")); 176 messg->setText(QObject::tr("Looking for modem..."));
176 inittimer->start(100); 177 inittimer->start(100);
177} 178}
178 179
179 180
180void ConnectWidget::init() { 181void ConnectWidget::init() {
181 _ifaceppp->data()->setpppdError(0); 182 _ifaceppp->data()->setpppdError(0);
182 inittimer->stop(); 183 inittimer->stop();
183 vmain = 0; 184 vmain = 0;
184 substate = -1; 185 substate = -1;
185 expecting = false; 186 expecting = false;
186 pausing = false; 187 pausing = false;
187 scriptindex = 0; 188 scriptindex = 0;
188 myreadbuffer = ""; 189 myreadbuffer = "";
189 scanning = false; 190 scanning = false;
190 scanvar = ""; 191 scanvar = "";
191 firstrunID = true; 192 firstrunID = true;
192 firstrunPW = true; 193 firstrunPW = true;
193// stats->totalbytes = 0; 194// stats->totalbytes = 0;
194 dialnumber = 0; 195 dialnumber = 0;
195 196
196// p_kppp->con_speed = ""; 197// p_kppp->con_speed = "";
197 198
198// p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || _ifaceppp->data()->quit_on_disconnect()); 199// p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || _ifaceppp->data()->quit_on_disconnect());
199 200
200 comlist = &_ifaceppp->data()->scriptType(); 201 comlist = &_ifaceppp->data()->scriptType();
201 arglist = &_ifaceppp->data()->script(); 202 arglist = &_ifaceppp->data()->script();
202 203
203 QString tit = QObject::tr("Connecting to: %1").arg(_ifaceppp->data()->accname()); 204 QString tit = QObject::tr("Connecting to: %1").arg(_ifaceppp->data()->accname());
204 setCaption(tit); 205 setCaption(tit);
205 206
206 qApp->processEvents(); 207 qApp->processEvents();
207 208
208 // run the "before-connect" command 209 // run the "before-connect" command
209 if (!_ifaceppp->data()->command_before_connect().isEmpty()) { 210 if (!_ifaceppp->data()->command_before_connect().isEmpty()) {
210 messg->setText(QObject::tr("Running pre-startup command...")); 211 messg->setText(QObject::tr("Running pre-startup command..."));
211 emit debugMessage(QObject::tr("Running pre-startup command...")); 212 emit debugMessage(QObject::tr("Running pre-startup command..."));
212 213
213 qApp->processEvents(); 214 qApp->processEvents();
214 QApplication::flushX(); 215 QApplication::flushX();
215 pid_t id = execute_command(_ifaceppp->data()->command_before_connect()); 216 pid_t id = execute_command(_ifaceppp->data()->command_before_connect());
216// int i, status; 217// int i, status;
217 218
218// do { 219// do {
219// qApp->processEvents(); 220// qApp->processEvents();
220// i = waitpid(id, &status, WNOHANG); 221// i = waitpid(id, &status, WNOHANG);
221// usleep(100000); 222// usleep(100000);
222// } while (i == 0 && errno == 0); 223// } while (i == 0 && errno == 0);
223 } 224 }
224 225
225 int lock = _ifaceppp->modem()->lockdevice(); 226 int lock = _ifaceppp->modem()->lockdevice();
226 227
227 if (lock == 1) { 228 if (lock == 1) {
228 messg->setText(QObject::tr("Modem device is locked.")); 229 messg->setText(QObject::tr("Modem device is locked."));
229 vmain = 20; // wait until cancel is pressed 230 vmain = 20; // wait until cancel is pressed
230 return; 231 return;
231 } 232 }
232 233
233 if (lock == -1) { 234 if (lock == -1) {
234 messg->setText(QObject::tr("Unable to create modem lock file.")); 235 messg->setText(QObject::tr("Unable to create modem lock file."));
235 vmain = 20; // wait until cancel is pressed 236 vmain = 20; // wait until cancel is pressed
236 return; 237 return;
237 } 238 }
238 239
239 if(_ifaceppp->modem()->opentty()) { 240 if(_ifaceppp->modem()->opentty()) {
240 messg->setText(_ifaceppp->modem()->modemMessage()); 241 messg->setText(_ifaceppp->modem()->modemMessage());
241 qApp->processEvents(); 242 qApp->processEvents();
242 if(_ifaceppp->modem()->hangup()) { 243 if(_ifaceppp->modem()->hangup()) {
243 244
244 qApp->processEvents(); 245 qApp->processEvents();
245 246
246 semaphore = false; 247 semaphore = false;
247 248
248 _ifaceppp->modem()->stop(); 249 _ifaceppp->modem()->stop();
249 _ifaceppp->modem()->notify(this, SLOT(readChar(unsigned char))); 250 _ifaceppp->modem()->notify(this, SLOT(readChar(unsigned char)));
250 251
251 // if we are stuck anywhere we will time out 252 // if we are stuck anywhere we will time out
252 timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); 253 timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000);
253 254
254 // this timer will run the script etc. 255 // this timer will run the script etc.
255 main_timer_ID = startTimer(10); 256 main_timer_ID = startTimer(10);
256 257
257 return; 258 return;
258 } 259 }
259 } 260 }
260 261
261 // initialization failed 262 // initialization failed
262 messg->setText(_ifaceppp->modem()->modemMessage()); 263 messg->setText(_ifaceppp->modem()->modemMessage());
263 vmain = 20; // wait until cancel is pressed 264 vmain = 20; // wait until cancel is pressed
264 _ifaceppp->modem()->unlockdevice(); 265 _ifaceppp->modem()->unlockdevice();
265} 266}
266 267
267 268
268void ConnectWidget::timerEvent(QTimerEvent *) { 269void ConnectWidget::timerEvent(QTimerEvent *) {
269 if (semaphore || pausing) 270 if (semaphore || pausing)
270 return; 271 return;
271 272
272 if(vmain == 0) { 273 if(vmain == 0) {
273#ifdef DEBUG_WO_DIALING 274#ifdef DEBUG_WO_DIALING
274 vmain = 10; 275 vmain = 10;
275 return; 276 return;
276#endif 277#endif
277 278
278 assert(PPPData::NumInitStrings > 0); 279 assert(PPPData::NumInitStrings > 0);
279 // first init string ? 280 // first init string ?
280 if(substate == -1) { 281 if(substate == -1) {
281 messg->setText(QObject::tr("Initializing modem...")); 282 messg->setText(QObject::tr("Initializing modem..."));
282 emit debugMessage(QObject::tr("Initializing modem...")); 283 emit debugMessage(QObject::tr("Initializing modem..."));
283 substate = 0; 284 substate = 0;
284 } 285 }
285 286
286 QString initStr = _ifaceppp->data()->modemInitStr(substate); 287 QString initStr = _ifaceppp->data()->modemInitStr(substate);
287 if (!initStr.isEmpty()) { 288 if (!initStr.isEmpty()) {
288 // send a carriage return and then wait a bit so that the modem will 289 // send a carriage return and then wait a bit so that the modem will
289 // let us issue commands. 290 // let us issue commands.
290 if(_ifaceppp->data()->modemPreInitDelay() > 0) { 291 if(_ifaceppp->data()->modemPreInitDelay() > 0) {
291 usleep(_ifaceppp->data()->modemPreInitDelay() * 5000); 292 usleep(_ifaceppp->data()->modemPreInitDelay() * 5000);
292 writeline(""); 293 writeline("");
293 usleep(_ifaceppp->data()->modemPreInitDelay() * 5000); 294 usleep(_ifaceppp->data()->modemPreInitDelay() * 5000);
294 } 295 }
295 setExpect(_ifaceppp->data()->modemInitResp()); 296 setExpect(_ifaceppp->data()->modemInitResp());
296 writeline(initStr); 297 writeline(initStr);
297 usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec 298 usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec
298 } 299 }
299 300
300 substate++; 301 substate++;
301 302
302 /* 303 /*
303 * FIXME after 3.0: Make it possible to disable ATS11 since it 304 * FIXME after 3.0: Make it possible to disable ATS11 since it
304 * seems to be incompatible with some ISDN adapters (e.g. DataBox 305 * seems to be incompatible with some ISDN adapters (e.g. DataBox
305 * Speed Dragon). Even better would be to detect this when doing 306 * Speed Dragon). Even better would be to detect this when doing
306 * a "Modem Query" 307 * a "Modem Query"
307 */ 308 */
308 if (MODEM_TONEDURATION != _ifaceppp->data()->modemToneDuration()) 309 if (MODEM_TONEDURATION != _ifaceppp->data()->modemToneDuration())
309 vmain = 5; 310 vmain = 5;
310 else 311 else
311 vmain = 3; 312 vmain = 3;
312 313
313 return; 314 return;
314 } 315 }
315 316
316 if (vmain == 5) { 317 if (vmain == 5) {
317 if(!expecting) { 318 if(!expecting) {
318 QString sToneDuration = "ATS11=" + QString::number(_ifaceppp->data()->modemToneDuration()); 319 QString sToneDuration = "ATS11=" + QString::number(_ifaceppp->data()->modemToneDuration());
319 QString msg = QObject::tr("Setting ") + sToneDuration; 320 QString msg = QObject::tr("Setting ") + sToneDuration;
320 messg->setText(msg); 321 messg->setText(msg);
321 emit debugMessage(msg); 322 emit debugMessage(msg);
322 setExpect(_ifaceppp->data()->modemInitResp()); 323 setExpect(_ifaceppp->data()->modemInitResp());
323 writeline(sToneDuration); 324 writeline(sToneDuration);
324 } 325 }
325 vmain = 3; 326 vmain = 3;
326 return; 327 return;
327 } 328 }
328 329
329 if(vmain == 3) { 330 if(vmain == 3) {
330 if(!expecting) { 331 if(!expecting) {
331 // done with all init strings ? 332 // done with all init strings ?
332 if(substate < PPPData::NumInitStrings) { 333 if(substate < PPPData::NumInitStrings) {
333 vmain = 0; 334 vmain = 0;
334 return; 335 return;
335 } 336 }
336 substate = -1; 337 substate = -1;
337 // skip setting the volume if command is empty 338 // skip setting the volume if command is empty
338 if(_ifaceppp->data()->volumeInitString().isEmpty()) { 339 if(_ifaceppp->data()->volumeInitString().isEmpty()) {
339 vmain = 4; 340 vmain = 4;
340 return; 341 return;
341 } 342 }
342 messg->setText(QObject::tr("Setting speaker volume...")); 343 messg->setText(QObject::tr("Setting speaker volume..."));
343 emit debugMessage(QObject::tr("Setting speaker volume...")); 344 emit debugMessage(QObject::tr("Setting speaker volume..."));
344 345
345 setExpect(_ifaceppp->data()->modemInitResp()); 346 setExpect(_ifaceppp->data()->modemInitResp());
346 QString vol("AT"); 347 QString vol("AT");
347 vol += _ifaceppp->data()->volumeInitString(); 348 vol += _ifaceppp->data()->volumeInitString();
348 writeline(vol); 349 writeline(vol);
349 usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec 350 usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec
350 vmain = 4; 351 vmain = 4;
351 return; 352 return;
352 } 353 }
353 } 354 }
354 355
355 if(vmain == 4) { 356 if(vmain == 4) {
356 if(!expecting) { 357 if(!expecting) {
357 if(!_ifaceppp->data()->waitForDialTone()) { 358 if(!_ifaceppp->data()->waitForDialTone()) {
358 QString msg = QObject::tr("Turning off dial tone waiting..."); 359 QString msg = QObject::tr("Turning off dial tone waiting...");
359 messg->setText(msg); 360 messg->setText(msg);
360 emit debugMessage(msg); 361 emit debugMessage(msg);
361 setExpect(_ifaceppp->data()->modemInitResp()); 362 setExpect(_ifaceppp->data()->modemInitResp());
362 writeline(_ifaceppp->data()->modemNoDialToneDetectionStr()); 363 writeline(_ifaceppp->data()->modemNoDialToneDetectionStr());
363 } 364 }
364 vmain = 1; 365 vmain = 1;
365 return; 366 return;
366 } 367 }
367 } 368 }
368 369
369 // dial the number and wait to connect 370 // dial the number and wait to connect
370 if(vmain == 1) { 371 if(vmain == 1) {
371 if(!expecting) { 372 if(!expecting) {
372 373
373 timeout_timer->stop(); 374 timeout_timer->stop();
374 timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); 375 timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000);
375 376
376 QStringList &plist = _ifaceppp->data()->phonenumbers(); 377 QStringList &plist = _ifaceppp->data()->phonenumbers();
377 QString bmarg= _ifaceppp->data()->dialPrefix(); 378 QString bmarg= _ifaceppp->data()->dialPrefix();
378 bmarg += *plist.at(dialnumber); 379 bmarg += *plist.at(dialnumber);
379 QString bm = QObject::tr("Dialing %1").arg(bmarg); 380 QString bm = QObject::tr("Dialing %1").arg(bmarg);
380 messg->setText(bm); 381 messg->setText(bm);
381 emit debugMessage(bm); 382 emit debugMessage(bm);
382 383
383 QString pn = _ifaceppp->data()->modemDialStr(); 384 QString pn = _ifaceppp->data()->modemDialStr();
384 pn += _ifaceppp->data()->dialPrefix(); 385 pn += _ifaceppp->data()->dialPrefix();
385 pn += *plist.at(dialnumber); 386 pn += *plist.at(dialnumber);
386 if(++dialnumber >= plist.count()) 387 if(++dialnumber >= plist.count())
387 dialnumber = 0; 388 dialnumber = 0;
388 writeline(pn); 389 writeline(pn);
389 390
390 setExpect(_ifaceppp->data()->modemConnectResp()); 391 setExpect(_ifaceppp->data()->modemConnectResp());
391 vmain = 100; 392 vmain = 100;
392 return; 393 return;
393 } 394 }
394 } 395 }
395 396
396 // wait for connect, but redial if BUSY or wait for user cancel 397 // wait for connect, but redial if BUSY or wait for user cancel
397 // if NO CARRIER or NO DIALTONE 398 // if NO CARRIER or NO DIALTONE
398 if(vmain == 100) { 399 if(vmain == 100) {
399 if(!expecting) { 400 if(!expecting) {
400 myreadbuffer = _ifaceppp->data()->modemConnectResp(); 401 myreadbuffer = _ifaceppp->data()->modemConnectResp();
401 setExpect("\n"); 402 setExpect("\n");
402 vmain = 101; 403 vmain = 101;
403 return; 404 return;
404 } 405 }
405 406
406 if(readbuffer.contains(_ifaceppp->data()->modemBusyResp())) { 407 if(readbuffer.contains(_ifaceppp->data()->modemBusyResp())) {
407 timeout_timer->stop(); 408 timeout_timer->stop();
408 timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); 409 timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000);
409 410
410 messg->setText(QObject::tr("Line busy. Hanging up...")); 411 messg->setText(QObject::tr("Line busy. Hanging up..."));
411 emit debugPutChar('\n'); 412 emit debugPutChar('\n');
412 _ifaceppp->modem()->hangup(); 413 _ifaceppp->modem()->hangup();
413 414
414 if(_ifaceppp->data()->busyWait() > 0) { 415 if(_ifaceppp->data()->busyWait() > 0) {
415 QString bm = QObject::tr("Line busy. Waiting: %1 seconds").arg(_ifaceppp->data()->busyWait()); 416 QString bm = QObject::tr("Line busy. Waiting: %1 seconds").arg(_ifaceppp->data()->busyWait());
416 messg->setText(bm); 417 messg->setText(bm);
417 emit debugMessage(bm); 418 emit debugMessage(bm);
418 419
419 pausing = true; 420 pausing = true;
420 421
421 pausetimer->start(_ifaceppp->data()->busyWait()*1000, true); 422 pausetimer->start(_ifaceppp->data()->busyWait()*1000, true);
422 timeout_timer->stop(); 423 timeout_timer->stop();
423 } 424 }
424 425
425 _ifaceppp->modem()->setDataMode(false); 426 _ifaceppp->modem()->setDataMode(false);
426 vmain = 0; 427 vmain = 0;
427 substate = -1; 428 substate = -1;
428 return; 429 return;
429 } 430 }
430 431
431 if(readbuffer.contains(_ifaceppp->data()->modemNoDialtoneResp())) { 432 if(readbuffer.contains(_ifaceppp->data()->modemNoDialtoneResp())) {
432 timeout_timer->stop(); 433 timeout_timer->stop();
433 434
434 messg->setText(QObject::tr("No Dialtone")); 435 messg->setText(QObject::tr("No Dialtone"));
435 vmain = 20; 436 vmain = 20;
436 _ifaceppp->modem()->unlockdevice(); 437 _ifaceppp->modem()->unlockdevice();
437 return; 438 return;
438 } 439 }
439 440
440 if(readbuffer.contains(_ifaceppp->data()->modemNoCarrierResp())) { 441 if(readbuffer.contains(_ifaceppp->data()->modemNoCarrierResp())) {
441 timeout_timer->stop(); 442 timeout_timer->stop();
442 443
443 messg->setText(QObject::tr("No Carrier")); 444 messg->setText(QObject::tr("No Carrier"));
444 vmain = 20; 445 vmain = 20;
445 _ifaceppp->modem()->unlockdevice(); 446 _ifaceppp->modem()->unlockdevice();
446 return; 447 return;
447 } 448 }
448 } 449 }
449 450
450 // wait for newline after CONNECT response (so we get the speed) 451 // wait for newline after CONNECT response (so we get the speed)
451 if(vmain == 101) { 452 if(vmain == 101) {
452 if(!expecting) { 453 if(!expecting) {
453 _ifaceppp->modem()->setDataMode(true); // modem will no longer respond to AT commands 454 _ifaceppp->modem()->setDataMode(true); // modem will no longer respond to AT commands
454 455
455 emit startAccounting(); 456 emit startAccounting();
456// p_kppp->con_win->startClock(); 457// p_kppp->con_win->startClock();
457 458
458 vmain = 2; 459 vmain = 2;
459 scriptTimeout=_ifaceppp->data()->modemTimeout()*1000; 460 scriptTimeout=_ifaceppp->data()->modemTimeout()*1000;
460 return; 461 return;
461 } 462 }
462 } 463 }
463 464
464 // execute the script 465 // execute the script
465 if(vmain == 2) { 466 if(vmain == 2) {
466 if(!expecting && !pausing && !scanning) { 467 if(!expecting && !pausing && !scanning) {
467 468
468 timeout_timer->stop(); 469 timeout_timer->stop();
469 timeout_timer->start(scriptTimeout); 470 timeout_timer->start(scriptTimeout);
470 471
471 if((unsigned) scriptindex < comlist->count()) { 472 if((unsigned) scriptindex < comlist->count()) {
472 scriptCommand = *(comlist->at(scriptindex)); 473 scriptCommand = *(comlist->at(scriptindex));
473 scriptArgument = *(arglist->at(scriptindex)); 474 scriptArgument = *(arglist->at(scriptindex));
474 } else { 475 } else {
475 odebug << "End of script" << oendl; 476 odebug << "End of script" << oendl;
476 vmain = 10; 477 vmain = 10;
477 return; 478 return;
478 } 479 }
479 480
480 if (scriptCommand == "Scan") { 481 if (scriptCommand == "Scan") {
481 QString bm = QObject::tr("Scanning %1").arg(scriptArgument); 482 QString bm = QObject::tr("Scanning %1").arg(scriptArgument);
482 messg->setText(bm); 483 messg->setText(bm);
483 emit debugMessage(bm); 484 emit debugMessage(bm);
484 485
485 setScan(scriptArgument); 486 setScan(scriptArgument);
486 scriptindex++; 487 scriptindex++;
487 return; 488 return;
488 } 489 }
489 490
490 if (scriptCommand == "Save") { 491 if (scriptCommand == "Save") {
491 QString bm = QObject::tr("Saving %1").arg(scriptArgument); 492 QString bm = QObject::tr("Saving %1").arg(scriptArgument);
492 messg->setText(bm); 493 messg->setText(bm);
493 emit debugMessage(bm); 494 emit debugMessage(bm);
494 495
495 if (scriptArgument.lower() == "password") { 496 if (scriptArgument.lower() == "password") {
496 _ifaceppp->data()->setPassword(scanvar); 497 _ifaceppp->data()->setPassword(scanvar);
497 // p_kppp->setPW_Edit(scanvar); 498 // p_kppp->setPW_Edit(scanvar);
498 if(_ifaceppp->data()->storePassword()) 499 if(_ifaceppp->data()->storePassword())
499 _ifaceppp->data()->setStoredPassword(scanvar); 500 _ifaceppp->data()->setStoredPassword(scanvar);
500 firstrunPW = true; 501 firstrunPW = true;
501 } 502 }
502 503
503 scriptindex++; 504 scriptindex++;
504 return; 505 return;
505 } 506 }
506 507
507 508
508 if (scriptCommand == "Send" || scriptCommand == "SendNoEcho") { 509 if (scriptCommand == "Send" || scriptCommand == "SendNoEcho") {
509 QString bm = QObject::tr("Sending %1"); 510 QString bm = QObject::tr("Sending %1");
510 511
511 // replace %USERNAME% and %PASSWORD% 512 // replace %USERNAME% and %PASSWORD%
512 QString arg = scriptArgument; 513 QString arg = scriptArgument;
513 QRegExp re1("%USERNAME%"); 514 QRegExp re1("%USERNAME%");
514 QRegExp re2("%PASSWORD%"); 515 QRegExp re2("%PASSWORD%");
515 arg = arg.replace(re1, _ifaceppp->data()->storedUsername()); 516 arg = arg.replace(re1, _ifaceppp->data()->storedUsername());
516 arg = arg.replace(re2, _ifaceppp->data()->storedPassword()); 517 arg = arg.replace(re2, _ifaceppp->data()->storedPassword());
517 518
518 if (scriptCommand == "Send") 519 if (scriptCommand == "Send")
519 bm = bm.arg(scriptArgument); 520 bm = bm.arg(scriptArgument);
520 else { 521 else {
521 for(uint i = 0; i < scriptArgument.length(); i++) 522 for(uint i = 0; i < scriptArgument.length(); i++)
522 bm = bm.arg("*"); 523 bm = bm.arg("*");
523 } 524 }
524 525
525 messg->setText(bm); 526 messg->setText(bm);
526 emit debugMessage(bm); 527 emit debugMessage(bm);
527 528
528 writeline(scriptArgument); 529 writeline(scriptArgument);
529 scriptindex++; 530 scriptindex++;
530 return; 531 return;
531 } 532 }
532 533
533 if (scriptCommand == "Expect") { 534 if (scriptCommand == "Expect") {
534 QString bm = QObject::tr("Expecting %1").arg(scriptArgument); 535 QString bm = QObject::tr("Expecting %1").arg(scriptArgument);
535 messg->setText(bm); 536 messg->setText(bm);
536 emit debugMessage(bm); 537 emit debugMessage(bm);
537 538
538 // The incrementing of the scriptindex MUST be before the 539 // The incrementing of the scriptindex MUST be before the
539 // call to setExpect otherwise the expect will miss a string that is 540 // call to setExpect otherwise the expect will miss a string that is
540 // already in the buffer. 541 // already in the buffer.
541 scriptindex++; 542 scriptindex++;
542 setExpect(scriptArgument); 543 setExpect(scriptArgument);
543 return; 544 return;
544 } 545 }
545 546
546 547
547 if (scriptCommand == "Pause") { 548 if (scriptCommand == "Pause") {
548 QString bm = QObject::tr("Pause %1 seconds").arg(scriptArgument); 549 QString bm = QObject::tr("Pause %1 seconds").arg(scriptArgument);
549 messg->setText(bm); 550 messg->setText(bm);
550 emit debugMessage(bm); 551 emit debugMessage(bm);
551 552
552 pausing = true; 553 pausing = true;
553 554
554 pausetimer->start(scriptArgument.toInt()*1000, true); 555 pausetimer->start(scriptArgument.toInt()*1000, true);
555 timeout_timer->stop(); 556 timeout_timer->stop();
556 557
557 scriptindex++; 558 scriptindex++;
558 return; 559 return;
559 } 560 }
560 561
561 if (scriptCommand == "Timeout") { 562 if (scriptCommand == "Timeout") {
562 563
563 timeout_timer->stop(); 564 timeout_timer->stop();
564 565
565 QString bm = QObject::tr("Timeout %1 seconds").arg(scriptArgument); 566 QString bm = QObject::tr("Timeout %1 seconds").arg(scriptArgument);
566 messg->setText(bm); 567 messg->setText(bm);
567 emit debugMessage(bm); 568 emit debugMessage(bm);
568 569
569 scriptTimeout=scriptArgument.toInt()*1000; 570 scriptTimeout=scriptArgument.toInt()*1000;
570 timeout_timer->start(scriptTimeout); 571 timeout_timer->start(scriptTimeout);
571 572
572 scriptindex++; 573 scriptindex++;
573 return; 574 return;
574 } 575 }
575 576
576 if (scriptCommand == "Hangup") { 577 if (scriptCommand == "Hangup") {
577 messg->setText(QObject::tr("Hangup")); 578 messg->setText(QObject::tr("Hangup"));
578 emit debugMessage(QObject::tr("Hangup")); 579 emit debugMessage(QObject::tr("Hangup"));
579 580
580 writeline(_ifaceppp->data()->modemHangupStr()); 581 writeline(_ifaceppp->data()->modemHangupStr());
581 setExpect(_ifaceppp->data()->modemHangupResp()); 582 setExpect(_ifaceppp->data()->modemHangupResp());
582 583
583 scriptindex++; 584 scriptindex++;
584 return; 585 return;
585 } 586 }
586 587
587 if (scriptCommand == "Answer") { 588 if (scriptCommand == "Answer") {
588 589
589 timeout_timer->stop(); 590 timeout_timer->stop();
590 591
591 messg->setText(QObject::tr("Answer")); 592 messg->setText(QObject::tr("Answer"));
592 emit debugMessage(QObject::tr("Answer")); 593 emit debugMessage(QObject::tr("Answer"));
593 594
594 setExpect(_ifaceppp->data()->modemRingResp()); 595 setExpect(_ifaceppp->data()->modemRingResp());
595 vmain = 150; 596 vmain = 150;
596 return; 597 return;
597 } 598 }
598 599
599 if (scriptCommand == "ID") { 600 if (scriptCommand == "ID") {
600 QString bm = QObject::tr("ID %1").arg(scriptArgument); 601 QString bm = QObject::tr("ID %1").arg(scriptArgument);
601 messg->setText(bm); 602 messg->setText(bm);
602 emit debugMessage(bm); 603 emit debugMessage(bm);
603 604
604 QString idstring = _ifaceppp->data()->password(); 605 QString idstring = _ifaceppp->data()->password();
605 606
606 if(!idstring.isEmpty() && firstrunID) { 607 if(!idstring.isEmpty() && firstrunID) {
607 // the user entered an Id on the main kppp dialog 608 // the user entered an Id on the main kppp dialog
608 writeline(idstring); 609 writeline(idstring);
609 firstrunID = false; 610 firstrunID = false;
610 scriptindex++; 611 scriptindex++;
611 } 612 }
612 else { 613 else {
613 // the user didn't enter and Id on the main kppp dialog 614 // the user didn't enter and Id on the main kppp dialog
614 // let's query for an ID 615 // let's query for an ID
615 /* if not around yet, then post window... */ 616 /* if not around yet, then post window... */
616 if (prompt->Consumed()) { 617 if (prompt->Consumed()) {
617 if (!(prompt->isVisible())) { 618 if (!(prompt->isVisible())) {
618 prompt->setPrompt(scriptArgument); 619 prompt->setPrompt(scriptArgument);
619 prompt->setEchoModeNormal(); 620 prompt->setEchoModeNormal();
620 prompt->show(); 621 prompt->show();
621 } 622 }
622 } else { 623 } else {
623 /* if prompt withdrawn ... then, */ 624 /* if prompt withdrawn ... then, */
624 if(!(prompt->isVisible())) { 625 if(!(prompt->isVisible())) {
625 writeline(prompt->text()); 626 writeline(prompt->text());
626 prompt->setConsumed(); 627 prompt->setConsumed();
627 scriptindex++; 628 scriptindex++;
628 return; 629 return;
629 } 630 }
630 /* replace timeout value */ 631 /* replace timeout value */
631 } 632 }
632 } 633 }
633 } 634 }
634 635
635 if (scriptCommand == "Password") { 636 if (scriptCommand == "Password") {
636 QString bm = QObject::tr("Password %1").arg(scriptArgument); 637 QString bm = QObject::tr("Password %1").arg(scriptArgument);
637 messg->setText(bm); 638 messg->setText(bm);
638 emit debugMessage(bm); 639 emit debugMessage(bm);
639 640
640 QString pwstring = _ifaceppp->data()->password(); 641 QString pwstring = _ifaceppp->data()->password();
641 642
642 if(!pwstring.isEmpty() && firstrunPW) { 643 if(!pwstring.isEmpty() && firstrunPW) {
643 // the user entered a password on the main kppp dialog 644 // the user entered a password on the main kppp dialog
644 writeline(pwstring); 645 writeline(pwstring);
645 firstrunPW = false; 646 firstrunPW = false;
646 scriptindex++; 647 scriptindex++;
647 } 648 }
648 else { 649 else {
649 // the user didn't enter a password on the main kppp dialog 650 // the user didn't enter a password on the main kppp dialog
650 // let's query for a password 651 // let's query for a password
651 /* if not around yet, then post window... */ 652 /* if not around yet, then post window... */
652 if (prompt->Consumed()) { 653 if (prompt->Consumed()) {
653 if (!(prompt->isVisible())) { 654 if (!(prompt->isVisible())) {
654 prompt->setPrompt(scriptArgument); 655 prompt->setPrompt(scriptArgument);
655 prompt->setEchoModePassword(); 656 prompt->setEchoModePassword();
656 prompt->show(); 657 prompt->show();
657 } 658 }
658 } else { 659 } else {
659 /* if prompt withdrawn ... then, */ 660 /* if prompt withdrawn ... then, */
660 if(!(prompt->isVisible())) { 661 if(!(prompt->isVisible())) {
661 // p_kppp->setPW_Edit(prompt->text()); 662 // p_kppp->setPW_Edit(prompt->text());
662 writeline(prompt->text()); 663 writeline(prompt->text());
663 prompt->setConsumed(); 664 prompt->setConsumed();
664 scriptindex++; 665 scriptindex++;
665 return; 666 return;
666 } 667 }
667 /* replace timeout value */ 668 /* replace timeout value */
668 } 669 }
669 } 670 }
670 } 671 }
671 672
672 if (scriptCommand == "Prompt") { 673 if (scriptCommand == "Prompt") {
673 QString bm = QObject::tr("Prompting %1"); 674 QString bm = QObject::tr("Prompting %1");
674 675
675 // if the scriptindex (aka the prompt text) includes a ## marker 676 // if the scriptindex (aka the prompt text) includes a ## marker
676 // this marker should get substituted with the contents of our stored 677 // this marker should get substituted with the contents of our stored
677 // variable (from the subsequent scan). 678 // variable (from the subsequent scan).
678 679
679 QString ts = scriptArgument; 680 QString ts = scriptArgument;
680 int vstart = ts.find( "##" ); 681 int vstart = ts.find( "##" );
681 if( vstart != -1 ) { 682 if( vstart != -1 ) {
682 ts.remove( vstart, 2 ); 683 ts.remove( vstart, 2 );
683 ts.insert( vstart, scanvar ); 684 ts.insert( vstart, scanvar );
684 } 685 }
685 686
686 bm = bm.arg(ts); 687 bm = bm.arg(ts);
687 messg->setText(bm); 688 messg->setText(bm);
688 emit debugMessage(bm); 689 emit debugMessage(bm);
689 690
690 /* if not around yet, then post window... */ 691 /* if not around yet, then post window... */
691 if (prompt->Consumed()) { 692 if (prompt->Consumed()) {
692 if (!(prompt->isVisible())) { 693 if (!(prompt->isVisible())) {
693 prompt->setPrompt( ts ); 694 prompt->setPrompt( ts );
694 prompt->setEchoModeNormal(); 695 prompt->setEchoModeNormal();
695 prompt->show(); 696 prompt->show();
696 } 697 }
697 } else { 698 } else {
698 /* if prompt withdrawn ... then, */ 699 /* if prompt withdrawn ... then, */
699 if (!(prompt->isVisible())) { 700 if (!(prompt->isVisible())) {
700 writeline(prompt->text()); 701 writeline(prompt->text());
701 prompt->setConsumed(); 702 prompt->setConsumed();
702 scriptindex++; 703 scriptindex++;
703 return; 704 return;
704 } 705 }
705 /* replace timeout value */ 706 /* replace timeout value */
706 } 707 }
707 } 708 }
708 709
709 if (scriptCommand == "PWPrompt") { 710 if (scriptCommand == "PWPrompt") {
710 QString bm = QObject::tr("PW Prompt %1").arg(scriptArgument); 711 QString bm = QObject::tr("PW Prompt %1").arg(scriptArgument);
711 messg->setText(bm); 712 messg->setText(bm);
712 emit debugMessage(bm); 713 emit debugMessage(bm);
713 714
714 /* if not around yet, then post window... */ 715 /* if not around yet, then post window... */
715 if (prompt->Consumed()) { 716 if (prompt->Consumed()) {
716 if (!(prompt->isVisible())) { 717 if (!(prompt->isVisible())) {
717 prompt->setPrompt(scriptArgument); 718 prompt->setPrompt(scriptArgument);
718 prompt->setEchoModePassword(); 719 prompt->setEchoModePassword();
719 prompt->show(); 720 prompt->show();
720 } 721 }
721 } else { 722 } else {
722 /* if prompt withdrawn ... then, */ 723 /* if prompt withdrawn ... then, */
723 if (!(prompt->isVisible())) { 724 if (!(prompt->isVisible())) {
724 writeline(prompt->text()); 725 writeline(prompt->text());
725 prompt->setConsumed(); 726 prompt->setConsumed();
726 scriptindex++; 727 scriptindex++;
727 return; 728 return;
728 } 729 }
729 /* replace timeout value */ 730 /* replace timeout value */
730 } 731 }
731 } 732 }
732 733
733 if (scriptCommand == "LoopStart") { 734 if (scriptCommand == "LoopStart") {
734 735
735 QString bm = QObject::tr("Loop Start %1").arg(scriptArgument); 736 QString bm = QObject::tr("Loop Start %1").arg(scriptArgument);
736 737
737 // The incrementing of the scriptindex MUST be before the 738 // The incrementing of the scriptindex MUST be before the
738 // call to setExpect otherwise the expect will miss a string that is 739 // call to setExpect otherwise the expect will miss a string that is
739 // already in the buffer. 740 // already in the buffer.
740 scriptindex++; 741 scriptindex++;
741 742
742 if ( loopnest > (MAXLOOPNEST-2) ) { 743 if ( loopnest > (MAXLOOPNEST-2) ) {
743 bm += QObject::tr("ERROR: Nested too deep, ignored."); 744 bm += QObject::tr("ERROR: Nested too deep, ignored.");
744 vmain=20; 745 vmain=20;
745 cancelbutton(); 746 cancelbutton();
746 QMessageBox::critical(0, "error", QObject::tr("Loops nested too deeply!")); 747 QMessageBox::critical(0, "error", QObject::tr("Loops nested too deeply!"));
747 } else { 748 } else {
748 setExpect(scriptArgument); 749 setExpect(scriptArgument);
749 loopstartindex[loopnest] = scriptindex; 750 loopstartindex[loopnest] = scriptindex;
750 loopstr[loopnest] = scriptArgument; 751 loopstr[loopnest] = scriptArgument;
751 loopend = false; 752 loopend = false;
752 loopnest++; 753 loopnest++;
753 } 754 }
754 messg->setText(bm); 755 messg->setText(bm);
755 emit debugMessage(bm); 756 emit debugMessage(bm);
756 757
757 } 758 }
758 759
759 if (scriptCommand == "LoopEnd") { 760 if (scriptCommand == "LoopEnd") {
760 QString bm = QObject::tr("Loop End %1").arg(scriptArgument); 761 QString bm = QObject::tr("Loop End %1").arg(scriptArgument);
761 if ( loopnest <= 0 ) { 762 if ( loopnest <= 0 ) {
762 bm = QObject::tr("LoopEnd without matching Start! Line: %1").arg(bm); 763 bm = QObject::tr("LoopEnd without matching Start! Line: %1").arg(bm);
763 vmain=20; 764 vmain=20;
764 cancelbutton(); 765 cancelbutton();
765 QMessageBox::critical(0, "error", bm); 766 QMessageBox::critical(0, "error", bm);
766 return; 767 return;
767 } else { 768 } else {
768 // NB! The incrementing of the scriptindex MUST be before the 769 // NB! The incrementing of the scriptindex MUST be before the
769 // call to setExpect otherwise the expect will miss a string 770 // call to setExpect otherwise the expect will miss a string
770 // that is already in the buffer. 771 // that is already in the buffer.
771 scriptindex++; 772 scriptindex++;
772 setExpect(scriptArgument); 773 setExpect(scriptArgument);
773 loopnest--; 774 loopnest--;
774 loopend = true; 775 loopend = true;
775 } 776 }
776 messg->setText(bm); 777 messg->setText(bm);
777 emit debugMessage(bm); 778 emit debugMessage(bm);
778 779
779 } 780 }
780 } 781 }
781 } 782 }
782 783
783 // this is a subroutine for the "Answer" script option 784 // this is a subroutine for the "Answer" script option
784 785
785 if(vmain == 150) { 786 if(vmain == 150) {
786 if(!expecting) { 787 if(!expecting) {
787 writeline(_ifaceppp->data()->modemAnswerStr()); 788 writeline(_ifaceppp->data()->modemAnswerStr());
788 setExpect(_ifaceppp->data()->modemAnswerResp()); 789 setExpect(_ifaceppp->data()->modemAnswerResp());
789 790
790 vmain = 2; 791 vmain = 2;
791 scriptindex++; 792 scriptindex++;
792 return; 793 return;
793 } 794 }
794 } 795 }
795 796
796 if(vmain == 30) { 797 if(vmain == 30) {
797// if (termwindow->isVisible()) 798// if (termwindow->isVisible())
798// return; 799// return;
799// if (termwindow->pressedContinue()) 800// if (termwindow->pressedContinue())
800// vmain = 10; 801// vmain = 10;
801// else 802// else
802 cancelbutton(); 803 cancelbutton();
803 } 804 }
804 805
805 if(vmain == 10) { 806 if(vmain == 10) {
806 if(!expecting) { 807 if(!expecting) {
807 808
808 int result; 809 int result;
809 810
810 timeout_timer->stop(); 811 timeout_timer->stop();
811 if_timeout_timer->stop(); // better be sure. 812 if_timeout_timer->stop(); // better be sure.
812 813
813 // stop reading of data 814 // stop reading of data
814 _ifaceppp->modem()->stop(); 815 _ifaceppp->modem()->stop();
815 816
816 if(_ifaceppp->data()->authMethod() == AUTH_TERMINAL) { 817 if(_ifaceppp->data()->authMethod() == AUTH_TERMINAL) {
817 // if (termwindow) { 818 // if (termwindow) {
818 // delete termwindow; 819 // delete termwindow;
819 // termwindow = 0L; 820 // termwindow = 0L;
820 // this->show(); 821 // this->show();
821 // } else { 822 // } else {
822 // termwindow = new LoginTerm(0L, 0L); 823 // termwindow = new LoginTerm(0L, 0L);
823 // hide(); 824 // hide();
824 // termwindow->show(); 825 // termwindow->show();
825 // vmain = 30; 826 // vmain = 30;
826 // return; 827 // return;
827 // } 828 // }
828 } 829 }
829 830
830 // Close the tty. This prevents the QTimer::singleShot() in 831 // Close the tty. This prevents the QTimer::singleShot() in
831 // Modem::readtty() from re-enabling the socket notifier. 832 // Modem::readtty() from re-enabling the socket notifier.
832 // The port is still held open by the helper process. 833 // The port is still held open by the helper process.
833 834
834 /* Er, there _is_ not QTimer::singleShot() in Modem::readtty(), 835 /* Er, there _is_ not QTimer::singleShot() in Modem::readtty(),
835 and closing the thing prevents pppd from using it later. */ 836 and closing the thing prevents pppd from using it later. */
836 //_ifaceppp->modem()->closetty(); 837 //_ifaceppp->modem()->closetty();
837 838
838 killTimer( main_timer_ID ); 839 killTimer( main_timer_ID );
839 840
840 if_timeout_timer->start(_ifaceppp->data()->pppdTimeout()*1000); 841 if_timeout_timer->start(_ifaceppp->data()->pppdTimeout()*1000);
841 odebug << "started if timeout timer with " << _ifaceppp->data()->pppdTimeout()*1000 << "" << oendl; 842 odebug << "started if timeout timer with " << _ifaceppp->data()->pppdTimeout()*1000 << "" << oendl;
842 843
843 // find out PPP interface and notify the stats module 844 // find out PPP interface and notify the stats module
844// stats->setUnit(pppInterfaceNumber()); 845// stats->setUnit(pppInterfaceNumber());
845 846
846 qApp->flushX(); 847 qApp->flushX();
847 semaphore = true; 848 semaphore = true;
848 result = execppp(); 849 result = execppp();
849 850
850 emit debugMessage(QObject::tr("Starting pppd...")); 851 emit debugMessage(QObject::tr("Starting pppd..."));
851 odebug << "execppp() returned with return-code " << result << "" << oendl; 852 odebug << "execppp() returned with return-code " << result << "" << oendl;
852 853
853 if(result) { 854 if(result) {
854 if(!_ifaceppp->data()->autoDNS()) 855 if(!_ifaceppp->data()->autoDNS())
855 adddns( _ifaceppp ); 856 adddns( _ifaceppp );
856 857
857 // O.K we are done here, let's change over to the if_waiting loop 858 // O.K we are done here, let's change over to the if_waiting loop
858 // where we wait for the ppp if (interface) to come up. 859 // where we wait for the ppp if (interface) to come up.
859 860
860 emit if_waiting_signal(); 861 emit if_waiting_signal();
861 } else { 862 } else {
862 863
863 // starting pppd wasn't successful. Error messages were 864 // starting pppd wasn't successful. Error messages were
864 // handled by execppp(); 865 // handled by execppp();
865 if_timeout_timer->stop(); 866 if_timeout_timer->stop();
866 this->hide(); 867 this->hide();
867 messg->setText(""); 868 messg->setText("");
868 //p_kppp->quit_b->setFocus(); 869 //p_kppp->quit_b->setFocus();
869 //p_kppp->show(); 870 //p_kppp->show();
870 qApp->processEvents(); 871 qApp->processEvents();
871 _ifaceppp->modem()->hangup(); 872 _ifaceppp->modem()->hangup();
872 emit stopAccounting(); 873 emit stopAccounting();
873 //p_kppp->con_win->stopClock(); 874 //p_kppp->con_win->stopClock();
874 _ifaceppp->modem()->closetty(); 875 _ifaceppp->modem()->closetty();
875 _ifaceppp->modem()->unlockdevice(); 876 _ifaceppp->modem()->unlockdevice();
876 877
877 } 878 }
878 879
879 return; 880 return;
880 } 881 }
881 } 882 }
882 883
883 // this is a "wait until cancel" entry 884 // this is a "wait until cancel" entry
884 885
885 if(vmain == 20) { 886 if(vmain == 20) {
886 } 887 }
887} 888}
888 889
889 890
890void ConnectWidget::set_con_speed_string() { 891void ConnectWidget::set_con_speed_string() {
891 // Here we are trying to determine the speed at which we are connected. 892 // Here we are trying to determine the speed at which we are connected.
892 // Usually the modem responds after connect with something like 893 // Usually the modem responds after connect with something like
893 // CONNECT 115200, so all we need to do is find the number after CONNECT 894 // CONNECT 115200, so all we need to do is find the number after CONNECT
894 // or whatever the modemConnectResp() is. 895 // or whatever the modemConnectResp() is.
895// p_kppp->con_speed = _ifaceppp->modem()->parseModemSpeed(myreadbuffer); 896// p_kppp->con_speed = _ifaceppp->modem()->parseModemSpeed(myreadbuffer);
896} 897}
897 898
898 899
899 900
900void ConnectWidget::readChar(unsigned char c) { 901void ConnectWidget::readChar(unsigned char c) {
901 if(semaphore) 902 if(semaphore)
902 return; 903 return;
903 904
904 readbuffer += c; 905 readbuffer += c;
905 myreadbuffer += c; 906 myreadbuffer += c;
906 907
907 // While in scanning mode store each char to the scan buffer 908 // While in scanning mode store each char to the scan buffer
908 // for use in the prompt command 909 // for use in the prompt command
909 if( scanning ) 910 if( scanning )
910 scanbuffer += c; 911 scanbuffer += c;
911 912
912 // add to debug window 913 // add to debug window
913 emit debugPutChar(c); 914 emit debugPutChar(c);
914 915
915 checkBuffers(); 916 checkBuffers();
916} 917}
917 918
918 919
919void ConnectWidget::checkBuffers() { 920void ConnectWidget::checkBuffers() {
920 // Let's check if we are finished with scanning: 921 // Let's check if we are finished with scanning:
921 // The scanstring have to be in the buffer and the latest character 922 // The scanstring have to be in the buffer and the latest character
922 // was a carriage return or an linefeed (depending on modem setup) 923 // was a carriage return or an linefeed (depending on modem setup)
923 if( scanning && scanbuffer.contains(scanstr) && 924 if( scanning && scanbuffer.contains(scanstr) &&
924 ( scanbuffer.right(1) == "\n" || scanbuffer.right(1) == "\r") ) { 925 ( scanbuffer.right(1) == "\n" || scanbuffer.right(1) == "\r") ) {
925 scanning = false; 926 scanning = false;
926 927
927 int vstart = scanbuffer.find( scanstr ) + scanstr.length(); 928 int vstart = scanbuffer.find( scanstr ) + scanstr.length();
928 scanvar = scanbuffer.mid( vstart, scanbuffer.length() - vstart); 929 scanvar = scanbuffer.mid( vstart, scanbuffer.length() - vstart);
929 scanvar = scanvar.stripWhiteSpace(); 930 scanvar = scanvar.stripWhiteSpace();
930 931
931 // Show the Variabel content in the debug window 932 // Show the Variabel content in the debug window
932 QString sv = QObject::tr("Scan Var: %1").arg(scanvar); 933 QString sv = QObject::tr("Scan Var: %1").arg(scanvar);
933 emit debugMessage(sv); 934 emit debugMessage(sv);
934 } 935 }
935 936
936 if(expecting) { 937 if(expecting) {
937 if(readbuffer.contains(expectstr)) { 938 if(readbuffer.contains(expectstr)) {
938 expecting = false; 939 expecting = false;
939 // keep everything after the expected string 940 // keep everything after the expected string
940 readbuffer.remove(0, readbuffer.find(expectstr) + expectstr.length()); 941 readbuffer.remove(0, readbuffer.find(expectstr) + expectstr.length());
941 942
942 QString ts = QObject::tr("Found: %1").arg(expectstr); 943 QString ts = QObject::tr("Found: %1").arg(expectstr);
943 emit debugMessage(ts); 944 emit debugMessage(ts);
944 945
945 if (loopend) { 946 if (loopend) {
946 loopend=false; 947 loopend=false;
947 } 948 }
948 } 949 }
949 950
950 if (loopend && readbuffer.contains(loopstr[loopnest])) { 951 if (loopend && readbuffer.contains(loopstr[loopnest])) {
951 expecting = false; 952 expecting = false;
952 readbuffer = ""; 953 readbuffer = "";
953 QString ts = QObject::tr("Looping: %1").arg(loopstr[loopnest]); 954 QString ts = QObject::tr("Looping: %1").arg(loopstr[loopnest]);
954 emit debugMessage(ts); 955 emit debugMessage(ts);
955 scriptindex = loopstartindex[loopnest]; 956 scriptindex = loopstartindex[loopnest];
956 loopend = false; 957 loopend = false;
957 loopnest++; 958 loopnest++;
958 } 959 }
959 // notify event loop if expected string was found 960 // notify event loop if expected string was found
960 if(!expecting) 961 if(!expecting)
961 timerEvent((QTimerEvent *) 0); 962 timerEvent((QTimerEvent *) 0);
962 } 963 }
963} 964}
964 965
965 966
966 967
967void ConnectWidget::pause() { 968void ConnectWidget::pause() {
968 pausing = false; 969 pausing = false;
969 pausetimer->stop(); 970 pausetimer->stop();
970} 971}
971 972
972 973
973void ConnectWidget::cancelbutton() { 974void ConnectWidget::cancelbutton() {
974 _ifaceppp->modem()->stop(); 975 _ifaceppp->modem()->stop();
975 killTimer(main_timer_ID); 976 killTimer(main_timer_ID);
976 timeout_timer->stop(); 977 timeout_timer->stop();
977 if_timer->stop(); 978 if_timer->stop();
978 if_timeout_timer->stop(); 979 if_timeout_timer->stop();
979 980
980// if (termwindow) { 981// if (termwindow) {
981// delete termwindow; 982// delete termwindow;
982// termwindow = 0L; 983// termwindow = 0L;
983// this->show(); 984// this->show();
984// } 985// }
985 986
986 messg->setText(QObject::tr("One moment please...")); 987 messg->setText(QObject::tr("One moment please..."));
987 988
988 // just to be sure 989 // just to be sure
989 _ifaceppp->modem()->removeSecret(AUTH_PAP); 990 _ifaceppp->modem()->removeSecret(AUTH_PAP);
990 _ifaceppp->modem()->removeSecret(AUTH_CHAP); 991 _ifaceppp->modem()->removeSecret(AUTH_CHAP);
991 removedns(_ifaceppp); 992 removedns(_ifaceppp);
992 993
993 qApp->processEvents(); 994 qApp->processEvents();
994 995
995 _ifaceppp->modem()->killPPPDaemon(); 996 _ifaceppp->modem()->killPPPDaemon();
996 _ifaceppp->modem()->hangup(); 997 _ifaceppp->modem()->hangup();
997 998
998 999
999// p_kppp->quit_b->setFocus(); 1000// p_kppp->quit_b->setFocus();
1000// p_kppp->show(); 1001// p_kppp->show();
1001 // emit stopAccounting();// just to be sure 1002 // emit stopAccounting();// just to be sure
1002// p_kppp->con_win->stopClock(); 1003// p_kppp->con_win->stopClock();
1003 _ifaceppp->modem()->closetty(); 1004 _ifaceppp->modem()->closetty();
1004 _ifaceppp->modem()->unlockdevice(); 1005 _ifaceppp->modem()->unlockdevice();
1005 1006
1006 //abort prompt window... 1007 //abort prompt window...
1007 if (prompt->isVisible()) { 1008 if (prompt->isVisible()) {
1008 prompt->hide(); 1009 prompt->hide();
1009 } 1010 }
1010 prompt->setConsumed(); 1011 prompt->setConsumed();
1011 1012
1012 _ifaceppp->setStatus( false ); 1013 _ifaceppp->setStatus( false );
1013 _ifaceppp->refresh(); 1014 _ifaceppp->refresh();
1014// messg->setText(tr("offline")); 1015// messg->setText(tr("offline"));
1015 refresh(); 1016 refresh();
1016} 1017}
1017 1018
1018 1019
1019void ConnectWidget::script_timed_out() { 1020void ConnectWidget::script_timed_out() {
1020 if(vmain == 20) { // we are in the 'wait for the user to cancel' state 1021 if(vmain == 20) { // we are in the 'wait for the user to cancel' state
1021 timeout_timer->stop(); 1022 timeout_timer->stop();
1022 emit stopAccounting(); 1023 emit stopAccounting();
1023// p_kppp->con_win->stopClock(); 1024// p_kppp->con_win->stopClock();
1024 return; 1025 return;
1025 } 1026 }
1026 1027
1027 if (prompt->isVisible()) 1028 if (prompt->isVisible())
1028 prompt->hide(); 1029 prompt->hide();
1029 1030
1030 prompt->setConsumed(); 1031 prompt->setConsumed();
1031 messg->setText(QObject::tr("Script timed out!")); 1032 messg->setText(QObject::tr("Script timed out!"));
1032 _ifaceppp->modem()->hangup(); 1033 _ifaceppp->modem()->hangup();
1033 emit stopAccounting(); 1034 emit stopAccounting();
1034// p_kppp->con_win->stopClock(); 1035// p_kppp->con_win->stopClock();
1035 1036
1036 vmain = 0; // let's try again. 1037 vmain = 0; // let's try again.
1037 substate = -1; 1038 substate = -1;
1038} 1039}
1039 1040
1040 1041
1041void ConnectWidget::setScan(const QString &n) { 1042void ConnectWidget::setScan(const QString &n) {
1042 scanning = true; 1043 scanning = true;
1043 scanstr = n; 1044 scanstr = n;
1044 scanbuffer = ""; 1045 scanbuffer = "";
1045 1046
1046 QString ts = QObject::tr("Scanning: %1").arg(n); 1047 QString ts = QObject::tr("Scanning: %1").arg(n);
1047 emit debugMessage(ts); 1048 emit debugMessage(ts);
1048} 1049}
1049 1050
1050 1051
1051void ConnectWidget::setExpect(const QString &n) { 1052void ConnectWidget::setExpect(const QString &n) {
1052 expecting = true; 1053 expecting = true;
1053 expectstr = n; 1054 expectstr = n;
1054 1055
1055 QString ts = QObject::tr("Expecting: %1").arg(n); 1056 QString ts = QObject::tr("Expecting: %1").arg(n);
1056 ts.replace(QRegExp("\n"), "<LF>"); 1057 ts.replace(QRegExp("\n"), "<LF>");
1057 emit debugMessage(ts); 1058 emit debugMessage(ts);
1058 1059
1059 // check if the expected string is in the read buffer already. 1060 // check if the expected string is in the read buffer already.
1060 checkBuffers(); 1061 checkBuffers();
1061} 1062}
1062 1063
1063 1064
1064void ConnectWidget::if_waiting_timed_out() { 1065void ConnectWidget::if_waiting_timed_out() {
1065 if_timer->stop(); 1066 if_timer->stop();
1066 if_timeout_timer->stop(); 1067 if_timeout_timer->stop();
1067 odebug << "if_waiting_timed_out()" << oendl; 1068 odebug << "if_waiting_timed_out()" << oendl;
1068 1069
1069 _ifaceppp->data()->setpppdError(E_IF_TIMEOUT); 1070 _ifaceppp->data()->setpppdError(E_IF_TIMEOUT);
1070 1071
1071 // let's kill the stuck pppd 1072 // let's kill the stuck pppd
1072 _ifaceppp->modem()->killPPPDaemon(); 1073 _ifaceppp->modem()->killPPPDaemon();
1073 1074
1074 emit stopAccounting(); 1075 emit stopAccounting();
1075// p_kppp->con_win->stopClock(); 1076// p_kppp->con_win->stopClock();
1076 1077
1077 1078
1078 // killing ppp will generate a SIGCHLD which will be caught in pppdie() 1079 // killing ppp will generate a SIGCHLD which will be caught in pppdie()
1079 // in main.cpp what happens next will depend on the boolean 1080 // in main.cpp what happens next will depend on the boolean
1080 // reconnect_on_disconnect which is set in ConnectWidget::init(); 1081 // reconnect_on_disconnect which is set in ConnectWidget::init();
1081} 1082}
1082 1083
1083void ConnectWidget::pppdDied() 1084void ConnectWidget::pppdDied()
1084{ 1085{
1085 if_timer->stop(); 1086 if_timer->stop();
1086 if_timeout_timer->stop(); 1087 if_timeout_timer->stop();
1087} 1088}
1088 1089
1089void ConnectWidget::if_waiting_slot() { 1090void ConnectWidget::if_waiting_slot() {
1090 messg->setText(QObject::tr("Logging on to network...")); 1091 messg->setText(QObject::tr("Logging on to network..."));
1091 1092
1092// if(!stats->ifIsUp()) { 1093// if(!stats->ifIsUp()) {
1093 1094
1094// if(_ifaceppp->data()->pppdError() != 0) { 1095// if(_ifaceppp->data()->pppdError() != 0) {
1095// // we are here if pppd died immediately after starting it. 1096// // we are here if pppd died immediately after starting it.
1096// pppdDied(); 1097// pppdDied();
1097// // error message handled in main.cpp: sigPPPDDied() 1098// // error message handled in main.cpp: sigPPPDDied()
1098// return; 1099// return;
1099// } 1100// }
1100 1101
1101// if_timer->start(100, TRUE); // single shot 1102// if_timer->start(100, TRUE); // single shot
1102// return; 1103// return;
1103// } 1104// }
1104 1105
1105 // O.K the ppp interface is up and running 1106 // O.K the ppp interface is up and running
1106 // give it a few time to come up completly (0.2 seconds) 1107 // give it a few time to come up completly (0.2 seconds)
1107 if_timeout_timer->stop(); 1108 if_timeout_timer->stop();
1108 if_timer->stop(); 1109 if_timer->stop();
1109 usleep(200000); 1110 usleep(200000);
1110 1111
1111 if(_ifaceppp->data()->autoDNS()) 1112 if(_ifaceppp->data()->autoDNS())
1112 addpeerdns( _ifaceppp ); 1113 addpeerdns( _ifaceppp );
1113 1114
1114 // Close the debugging window. If we are connected, we 1115 // Close the debugging window. If we are connected, we
1115 // are not really interested in debug output 1116 // are not really interested in debug output
1116 emit closeDebugWindow(); 1117 emit closeDebugWindow();
1117// p_kppp->statdlg->take_stats(); // start taking ppp statistics 1118// p_kppp->statdlg->take_stats(); // start taking ppp statistics
1118 auto_hostname(_ifaceppp); 1119 auto_hostname(_ifaceppp);
1119 1120
1120 if(!_ifaceppp->data()->command_on_connect().isEmpty()) { 1121 if(!_ifaceppp->data()->command_on_connect().isEmpty()) {
1121 messg->setText(QObject::tr("Running startup command...")); 1122 messg->setText(QObject::tr("Running startup command..."));
1122 1123
1123 // make sure that we don't get any async errors 1124 // make sure that we don't get any async errors
1124 qApp->flushX(); 1125 qApp->flushX();
1125 execute_command(_ifaceppp->data()->command_on_connect()); 1126 execute_command(_ifaceppp->data()->command_on_connect());
1126 messg->setText(QObject::tr("Done")); 1127 messg->setText(QObject::tr("Done"));
1127 } 1128 }
1128 1129
1129 // remove the authentication file 1130 // remove the authentication file
1130 _ifaceppp->modem()->removeSecret(AUTH_PAP); 1131 _ifaceppp->modem()->removeSecret(AUTH_PAP);
1131 _ifaceppp->modem()->removeSecret(AUTH_CHAP); 1132 _ifaceppp->modem()->removeSecret(AUTH_CHAP);
1132 1133
1133 emit debugMessage(QObject::tr("Done")); 1134 emit debugMessage(QObject::tr("Done"));
1134 set_con_speed_string(); 1135 set_con_speed_string();
1135 1136
1136// p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed); 1137// p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed);
1137// this->hide(); 1138// this->hide();
1138// messg->setText(""); 1139// messg->setText("");
1139 1140
1140 _ifaceppp->setStatus( true ); 1141 _ifaceppp->setStatus( true );
1141 1142
1142 m_refreshTimer = new QTimer( this ); 1143 m_refreshTimer = new QTimer( this );
1143 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 1144 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
1144 m_refreshTimer->start( 3000 ); 1145 m_refreshTimer->start( 3000 );
1145 //_ifaceppp->refresh(); 1146 //_ifaceppp->refresh();
1146 // emit _ifaceppp->updateInterface(_ifaceppp); 1147 // emit _ifaceppp->updateInterface(_ifaceppp);
1147 1148
1148 // prepare the con_win so as to have the right size for 1149 // prepare the con_win so as to have the right size for
1149 // accounting / non-accounting mode 1150 // accounting / non-accounting mode
1150// if(p_kppp->acct != 0) 1151// if(p_kppp->acct != 0)
1151// p_kppp->con_win->accounting(p_kppp->acct->running()); 1152// p_kppp->con_win->accounting(p_kppp->acct->running());
1152// else 1153// else
1153// p_kppp->con_win->accounting(false); 1154// p_kppp->con_win->accounting(false);
1154 1155
1155// if (_ifaceppp->data()->get_dock_into_panel()) { 1156// if (_ifaceppp->data()->get_dock_into_panel()) {
1156// // DockWidget::dock_widget->show(); 1157// // DockWidget::dock_widget->show();
1157// // DockWidget::dock_widget->take_stats(); 1158// // DockWidget::dock_widget->take_stats();
1158// // this->hide(); 1159// // this->hide();
1159// } 1160// }
1160// else { 1161// else {
1161// // p_kppp->con_win->show(); 1162// // p_kppp->con_win->show();
1162 1163
1163// if(_ifaceppp->data()->get_iconify_on_connect()) { 1164// if(_ifaceppp->data()->get_iconify_on_connect()) {
1164// // p_kppp->con_win->showMinimized(); 1165// // p_kppp->con_win->showMinimized();
1165// } 1166// }
1166// } 1167// }
1167 1168
1168 _ifaceppp->modem()->closetty(); 1169 _ifaceppp->modem()->closetty();
1169} 1170}
1170 1171
1171void ConnectWidget::refresh() { 1172void ConnectWidget::refresh() {
1172 _ifaceppp->refresh(); 1173 _ifaceppp->refresh();
1173 if ( _ifaceppp->getStatus() ) { 1174 if ( _ifaceppp->getStatus() ) {
1174 messg->setText(QObject::tr("Online")); 1175 messg->setText(QObject::tr("Online"));
1175 } else { 1176 } else {
1176 messg->setText(QObject::tr("Offline")); 1177 messg->setText(QObject::tr("Offline"));
1177 } 1178 }
1178} 1179}
1179 1180
1180 1181
1181bool ConnectWidget::execppp() { 1182bool ConnectWidget::execppp() {
1182 QString command; 1183 QString command;
1183 1184
1184 command = "pppd"; 1185 command = "pppd";
1185 1186
1186 // as of version 2.3.6 pppd falls back to the real user rights when 1187 // as of version 2.3.6 pppd falls back to the real user rights when
1187 // opening a device given in a command line. To avoid permission conflicts 1188 // opening a device given in a command line. To avoid permission conflicts
1188 // we'll simply leave this argument away. pppd will then use the default tty 1189 // we'll simply leave this argument away. pppd will then use the default tty
1189 // which is the serial port we connected stdin/stdout to in opener.cpp. 1190 // which is the serial port we connected stdin/stdout to in opener.cpp.
1190 // command += " "; 1191 // command += " ";
1191 // command += _ifaceppp->data()->modemDevice(); 1192 // command += _ifaceppp->data()->modemDevice();
1192 1193
1193 command += " " + _ifaceppp->data()->speed(); 1194 command += " " + _ifaceppp->data()->speed();
1194 1195
1195 command += " -detach"; 1196 command += " -detach";
1196 1197
1197 if(_ifaceppp->data()->ipaddr() != "0.0.0.0" || 1198 if(_ifaceppp->data()->ipaddr() != "0.0.0.0" ||
1198 _ifaceppp->data()->gateway() != "0.0.0.0") { 1199 _ifaceppp->data()->gateway() != "0.0.0.0") {
1199 if(_ifaceppp->data()->ipaddr() != "0.0.0.0") { 1200 if(_ifaceppp->data()->ipaddr() != "0.0.0.0") {
1200 command += " "; 1201 command += " ";
1201 command += _ifaceppp->data()->ipaddr(); 1202 command += _ifaceppp->data()->ipaddr();
1202 command += ":"; 1203 command += ":";
1203 } 1204 }
1204 else { 1205 else {
1205 command += " "; 1206 command += " ";
1206 command += ":"; 1207 command += ":";
1207 } 1208 }
1208 1209
1209 if(_ifaceppp->data()->gateway() != "0.0.0.0") 1210 if(_ifaceppp->data()->gateway() != "0.0.0.0")
1210 command += _ifaceppp->data()->gateway(); 1211 command += _ifaceppp->data()->gateway();
1211 } 1212 }
1212 1213
1213 if(_ifaceppp->data()->subnetmask() != "0.0.0.0") 1214 if(_ifaceppp->data()->subnetmask() != "0.0.0.0")
1214 command += " netmask " + _ifaceppp->data()->subnetmask(); 1215 command += " netmask " + _ifaceppp->data()->subnetmask();
1215 1216
1216 if(_ifaceppp->data()->flowcontrol() != "None") { 1217 if(_ifaceppp->data()->flowcontrol() != "None") {
1217 if(_ifaceppp->data()->flowcontrol() == "CRTSCTS") 1218 if(_ifaceppp->data()->flowcontrol() == "CRTSCTS")
1218 command += " crtscts"; 1219 command += " crtscts";
1219 else 1220 else
1220 command += " xonxoff"; 1221 command += " xonxoff";
1221 } 1222 }
1222 1223
1223 if(_ifaceppp->data()->defaultroute()) 1224 if(_ifaceppp->data()->defaultroute())
1224 command += " defaultroute"; 1225 command += " defaultroute";
1225 1226
1226 if(_ifaceppp->data()->autoDNS()) 1227 if(_ifaceppp->data()->autoDNS())
1227 command += " usepeerdns"; 1228 command += " usepeerdns";
1228 1229
1229 1230
1230 // PAP settings 1231 // PAP settings
1231 if(_ifaceppp->data()->authMethod() == AUTH_PAP) { 1232 if(_ifaceppp->data()->authMethod() == AUTH_PAP) {
1232 command += " -chap user "; 1233 command += " -chap user ";
1233 command = command + _ifaceppp->data()->storedUsername(); 1234 command = command + _ifaceppp->data()->storedUsername();
1234 } 1235 }
1235 1236
1236 // CHAP settings 1237 // CHAP settings
1237 if(_ifaceppp->data()->authMethod() == AUTH_CHAP) { 1238 if(_ifaceppp->data()->authMethod() == AUTH_CHAP) {
1238 command += " -pap user "; 1239 command += " -pap user ";
1239 command = command + _ifaceppp->data()->storedUsername(); 1240 command = command + _ifaceppp->data()->storedUsername();
1240 } 1241 }
1241 1242
1242 // PAP/CHAP settings 1243 // PAP/CHAP settings
1243 if(_ifaceppp->data()->authMethod() == AUTH_PAPCHAP) { 1244 if(_ifaceppp->data()->authMethod() == AUTH_PAPCHAP) {
1244 QString tmpName = _ifaceppp->data()->storedUsername(); 1245 QString tmpName = _ifaceppp->data()->storedUsername();
1245 if ( !tmpName.isEmpty() ) { 1246 if ( !tmpName.isEmpty() ) {
1246 command += " user "; 1247 command += " user ";
1247 command = command + tmpName; 1248 command = command + tmpName;
1248 } 1249 }
1249 } 1250 }
1250 1251
1251 // check for debug 1252 // check for debug
1252 if(_ifaceppp->data()->getPPPDebug()) 1253 if(_ifaceppp->data()->getPPPDebug())
1253 command += " debug"; 1254 command += " debug";
1254 1255
1255 QStringList &arglist = _ifaceppp->data()->pppdArgument(); 1256 QStringList &arglist = _ifaceppp->data()->pppdArgument();
1256 for ( QStringList::Iterator it = arglist.begin(); 1257 for ( QStringList::Iterator it = arglist.begin();
1257 it != arglist.end(); 1258 it != arglist.end();
1258 ++it ) 1259 ++it )
1259 { 1260 {
1260 command += " " + *it; 1261 command += " " + *it;
1261 } 1262 }
1262 1263
1263 command += " call opie-kppp logfd 11"; 1264 command += " call opie-kppp logfd 11";
1264 1265
1265 if (command.length() > MAX_CMDLEN) { 1266 if (command.length() > MAX_CMDLEN) {
1266 QMessageBox::critical(this, "error", QObject::tr( 1267 QMessageBox::critical(this, "error", QObject::tr(
1267 "pppd command + command-line arguments exceed " 1268 "pppd command + command-line arguments exceed "
1268 "2024 characters in length." 1269 "2024 characters in length."
1269 )); 1270 ));
1270 1271
1271 return false; // nonsensically long command which would bust my buffer buf. 1272 return false; // nonsensically long command which would bust my buffer buf.
1272 } 1273 }
1273 1274
1274 owarn << "Command IS: " << command.latin1() << "" << oendl; 1275 owarn << "Command IS: " << command.latin1() << "" << oendl;
1275 1276
1276 qApp->flushX(); 1277 qApp->flushX();
1277 1278
1278 return _ifaceppp->modem()->execPPPDaemon(command); 1279 return _ifaceppp->modem()->execPPPDaemon(command);
1279} 1280}
1280 1281
1281 1282
1282void ConnectWidget::closeEvent( QCloseEvent *e ) { 1283void ConnectWidget::closeEvent( QCloseEvent *e ) {
1283 e->ignore(); 1284 e->ignore();
1284 emit cancelbutton(); 1285 emit cancelbutton();
1285} 1286}
1286 1287
1287 1288
1288void ConnectWidget::setMsg(const QString &msg) { 1289void ConnectWidget::setMsg(const QString &msg) {
1289 messg->setText(msg); 1290 messg->setText(msg);
1290} 1291}
1291 1292
1292void ConnectWidget::writeline(const QString &s) { 1293void ConnectWidget::writeline(const QString &s) {
1293 _ifaceppp->modem()->writeLine(s.local8Bit()); 1294 _ifaceppp->modem()->writeLine(s.local8Bit());
1294} 1295}
1295 1296
1296// Set the hostname and domain from DNS Server 1297// Set the hostname and domain from DNS Server
1297void auto_hostname(InterfacePPP *_ifaceppp) { 1298void auto_hostname(InterfacePPP *_ifaceppp) {
1298 struct in_addr local_ip; 1299 struct in_addr local_ip;
1299 struct hostent *hostname_entry; 1300 struct hostent *hostname_entry;
1300 QString new_hostname; 1301 QString new_hostname;
1301 int dot; 1302 int dot;
1302 char tmp_str[100]; // buffer overflow safe 1303 char tmp_str[100]; // buffer overflow safe
1303 1304
1304 gethostname(tmp_str, sizeof(tmp_str)); 1305 gethostname(tmp_str, sizeof(tmp_str));
1305 tmp_str[sizeof(tmp_str)-1]=0; // panic 1306 tmp_str[sizeof(tmp_str)-1]=0; // panic
1306 old_hostname=tmp_str; // copy to QString 1307 old_hostname=tmp_str; // copy to QString
1307 1308
1308 // if (!p_kppp->stats->local_ip_address.isEmpty() && _ifaceppp->data()->autoname()) { 1309 // if (!p_kppp->stats->local_ip_address.isEmpty() && _ifaceppp->data()->autoname()) {
1309 if ( _ifaceppp->data()->autoname()) { 1310 if ( _ifaceppp->data()->autoname()) {
1310// local_ip.s_addr=inet_addr(p_kppp->stats->local_ip_address.ascii()); 1311// local_ip.s_addr=inet_addr(p_kppp->stats->local_ip_address.ascii());
1311 hostname_entry=gethostbyaddr((const char *)&local_ip,sizeof(in_addr),AF_INET); 1312 hostname_entry=gethostbyaddr((const char *)&local_ip,sizeof(in_addr),AF_INET);
1312 1313
1313 if (hostname_entry != 0L) { 1314 if (hostname_entry != 0L) {
1314 new_hostname=hostname_entry->h_name; 1315 new_hostname=hostname_entry->h_name;
1315 dot=new_hostname.find('.'); 1316 dot=new_hostname.find('.');
1316 new_hostname=new_hostname.remove(dot,new_hostname.length()-dot); 1317 new_hostname=new_hostname.remove(dot,new_hostname.length()-dot);
1317 _ifaceppp->modem()->setHostname(new_hostname); 1318 _ifaceppp->modem()->setHostname(new_hostname);
1318 modified_hostname = TRUE; 1319 modified_hostname = TRUE;
1319 1320
1320 new_hostname=hostname_entry->h_name; 1321 new_hostname=hostname_entry->h_name;
1321 new_hostname.remove(0,dot+1); 1322 new_hostname.remove(0,dot+1);
1322 1323
1323 add_domain(new_hostname, _ifaceppp); 1324 add_domain(new_hostname, _ifaceppp);
1324 } 1325 }
1325 } 1326 }
1326 1327
1327} 1328}
1328 1329
1329// Replace the DNS domain entry in the /etc/resolv.conf file and 1330// Replace the DNS domain entry in the /etc/resolv.conf file and
1330// disable the nameserver entries if option is enabled 1331// disable the nameserver entries if option is enabled
1331void add_domain(const QString &domain, InterfacePPP *_ifaceppp) { 1332void add_domain(const QString &domain, InterfacePPP *_ifaceppp) {
1332 1333
1333 int fd; 1334 int fd;
1334 char c; 1335 char c;
1335 QString resolv[MAX_RESOLVCONF_LINES]; 1336 QString resolv[MAX_RESOLVCONF_LINES];
1336 1337
1337 if (domain.isEmpty()) 1338 if (domain.isEmpty())
1338 return; 1339 return;
1339 1340
1340 if((fd = _ifaceppp->modem()->openResolv(O_RDONLY)) >= 0) { 1341 if((fd = _ifaceppp->modem()->openResolv(O_RDONLY)) >= 0) {
1341 1342
1342 int i=0; 1343 int i=0;
1343 while((read(fd, &c, 1) == 1) && (i < MAX_RESOLVCONF_LINES)) { 1344 while((read(fd, &c, 1) == 1) && (i < MAX_RESOLVCONF_LINES)) {
1344 if(c == '\n') { 1345 if(c == '\n') {
1345 i++; 1346 i++;
1346 } 1347 }
1347 else { 1348 else {
1348 resolv[i] += c; 1349 resolv[i] += c;
1349 } 1350 }
1350 } 1351 }
1351 close(fd); 1352 close(fd);
1352 if ((c != '\n') && (i < MAX_RESOLVCONF_LINES)) i++; 1353 if ((c != '\n') && (i < MAX_RESOLVCONF_LINES)) i++;
1353 1354
1354 if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_TRUNC)) >= 0) { 1355 if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_TRUNC)) >= 0) {
1355 QCString tmp = "domain " + domain.local8Bit() + 1356 QCString tmp = "domain " + domain.local8Bit() +
1356 " \t\t#kppp temp entry\n"; 1357 " \t\t#kppp temp entry\n";
1357 write(fd, tmp.data(), tmp.length()); 1358 write(fd, tmp.data(), tmp.length());
1358 1359
1359 for(int j=0; j < i; j++) { 1360 for(int j=0; j < i; j++) {
1360 if((resolv[j].contains("domain") || 1361 if((resolv[j].contains("domain") ||
1361 ( resolv[j].contains("nameserver") 1362 ( resolv[j].contains("nameserver")
1362 && !resolv[j].contains("#kppp temp entry") 1363 && !resolv[j].contains("#kppp temp entry")
1363 && _ifaceppp->data()->exDNSDisabled())) 1364 && _ifaceppp->data()->exDNSDisabled()))
1364 && !resolv[j].contains("#entry disabled by kppp")) { 1365 && !resolv[j].contains("#entry disabled by kppp")) {
1365 QCString tmp = "# " + resolv[j].local8Bit() + 1366 QCString tmp = "# " + resolv[j].local8Bit() +
1366 " \t#entry disabled by kppp\n"; 1367 " \t#entry disabled by kppp\n";
1367 write(fd, tmp, tmp.length()); 1368 write(fd, tmp, tmp.length());
1368 } 1369 }
1369 else { 1370 else {
1370 QCString tmp = resolv[j].local8Bit() + "\n"; 1371 QCString tmp = resolv[j].local8Bit() + "\n";
1371 write(fd, tmp, tmp.length()); 1372 write(fd, tmp, tmp.length());
1372 } 1373 }
1373 } 1374 }
1374 } 1375 }
1375 close(fd); 1376 close(fd);
1376 } 1377 }
1377} 1378}
1378 1379
1379 1380
1380// adds the DNS entries in the /etc/resolv.conf file 1381// adds the DNS entries in the /etc/resolv.conf file
1381void adddns( InterfacePPP *_ifaceppp) 1382void adddns( InterfacePPP *_ifaceppp)
1382{ 1383{
1383 int fd; 1384 int fd;
1384 1385
1385 if ((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_APPEND)) >= 0) { 1386 if ((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_APPEND)) >= 0) {
1386 QStringList &dnslist = _ifaceppp->data()->dns(); 1387 QStringList &dnslist = _ifaceppp->data()->dns();
1387 for ( QStringList::Iterator it = dnslist.begin(); 1388 for ( QStringList::Iterator it = dnslist.begin();
1388 it != dnslist.end(); 1389 it != dnslist.end();
1389 ++it ) 1390 ++it )
1390 { 1391 {
1391 QCString dns = "nameserver " + (*it).local8Bit() + 1392 QCString dns = "nameserver " + (*it).local8Bit() +
1392 " \t#kppp temp entry\n"; 1393 " \t#kppp temp entry\n";
1393 write(fd, dns.data(), dns.length()); 1394 write(fd, dns.data(), dns.length());
1394 } 1395 }
1395 close(fd); 1396 close(fd);
1396 } 1397 }
1397 add_domain(_ifaceppp->data()->domain(), _ifaceppp); 1398 add_domain(_ifaceppp->data()->domain(), _ifaceppp);
1398} 1399}
1399 1400
1400void addpeerdns(InterfacePPP *_ifaceppp) { 1401void addpeerdns(InterfacePPP *_ifaceppp) {
1401 int fd, fd2; 1402 int fd, fd2;
1402 1403
1403 if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_APPEND)) >= 0) { 1404 if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_APPEND)) >= 0) {
1404 if((fd2 = open("/etc/ppp/resolv.conf", O_RDONLY)) >= 0) { 1405 if((fd2 = open("/etc/ppp/resolv.conf", O_RDONLY)) >= 0) {
1405 char c; 1406 char c;
1406 int i = 0; 1407 int i = 0;
1407 while(i++ < 100 && read(fd2, &c, 1) == 1) { 1408 while(i++ < 100 && read(fd2, &c, 1) == 1) {
1408 if(c == '\n') 1409 if(c == '\n')
1409 write(fd, "\t#kppp temp entry\n", 18); 1410 write(fd, "\t#kppp temp entry\n", 18);
1410 else 1411 else
1411 write(fd, &c, 1); 1412 write(fd, &c, 1);
1412 } 1413 }
1413 close(fd2); 1414 close(fd2);
1414 } else 1415 } else
1415 fprintf(stderr, "failed to read from /etc/ppp/resolv.conf\n"); 1416 fprintf(stderr, "failed to read from /etc/ppp/resolv.conf\n");
1416 close(fd); 1417 close(fd);
1417 } 1418 }
1418 add_domain(_ifaceppp->data()->domain(), _ifaceppp); 1419 add_domain(_ifaceppp->data()->domain(), _ifaceppp);
1419} 1420}
1420 1421
1421// remove the dns entries from the /etc/resolv.conf file 1422// remove the dns entries from the /etc/resolv.conf file
1422void removedns(InterfacePPP *_ifaceppp) { 1423void removedns(InterfacePPP *_ifaceppp) {
1423 1424
1424 int fd; 1425 int fd;
1425 char c; 1426 char c;
1426 QString resolv[MAX_RESOLVCONF_LINES]; 1427 QString resolv[MAX_RESOLVCONF_LINES];
1427 1428
1428 if((fd = _ifaceppp->modem()->openResolv(O_RDONLY)) >= 0) { 1429 if((fd = _ifaceppp->modem()->openResolv(O_RDONLY)) >= 0) {
1429 1430
1430 int i=0; 1431 int i=0;
1431 while(read(fd, &c, 1) == 1 && i < MAX_RESOLVCONF_LINES) { 1432 while(read(fd, &c, 1) == 1 && i < MAX_RESOLVCONF_LINES) {
1432 if(c == '\n') { 1433 if(c == '\n') {
1433 i++; 1434 i++;
1434 } 1435 }
1435 else { 1436 else {
1436 resolv[i] += c; 1437 resolv[i] += c;
1437 } 1438 }
1438 } 1439 }
1439 close(fd); 1440 close(fd);
1440 1441
1441 if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_TRUNC)) >= 0) { 1442 if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_TRUNC)) >= 0) {
1442 for(int j=0; j < i; j++) { 1443 for(int j=0; j < i; j++) {
1443 if(resolv[j].contains("#kppp temp entry")) continue; 1444 if(resolv[j].contains("#kppp temp entry")) continue;
1444 if(resolv[j].contains("#entry disabled by kppp")) { 1445 if(resolv[j].contains("#entry disabled by kppp")) {
1445 QCString tmp = resolv[j].local8Bit(); 1446 QCString tmp = resolv[j].local8Bit();
1446 write(fd, tmp.data()+2, tmp.length() - 27); 1447 write(fd, tmp.data()+2, tmp.length() - 27);
1447 write(fd, "\n", 1); 1448 write(fd, "\n", 1);
1448 } 1449 }
1449 else { 1450 else {
1450 QCString tmp = resolv[j].local8Bit() + "\n"; 1451 QCString tmp = resolv[j].local8Bit() + "\n";
1451 write(fd, tmp, tmp.length()); 1452 write(fd, tmp, tmp.length());
1452 } 1453 }
1453 } 1454 }
1454 } 1455 }
1455 close(fd); 1456 close(fd);
1456 1457
1457 } 1458 }
1458 1459
1459 if ( modified_hostname ) { 1460 if ( modified_hostname ) {
1460 _ifaceppp->modem()->setHostname(old_hostname); 1461 _ifaceppp->modem()->setHostname(old_hostname);
1461 modified_hostname = FALSE; 1462 modified_hostname = FALSE;
1462 } 1463 }
1463 1464
1464} 1465}
1465 1466
1466 1467
diff --git a/noncore/settings/networksettings/ppp/devices.cpp b/noncore/settings/networksettings/ppp/devices.cpp
index 350ff32..42de44c 100644
--- a/noncore/settings/networksettings/ppp/devices.cpp
+++ b/noncore/settings/networksettings/ppp/devices.cpp
@@ -1,217 +1,219 @@
1/* 1/*
2 * kPPP: A pppd front end for the KDE project 2 * kPPP: A pppd front end for the KDE project
3 * 3 *
4 * $Id$ 4 * $Id$
5 * 5 *
6 * Copyright (C) 1997 Bernd Johannes Wuebben 6 * Copyright (C) 1997 Bernd Johannes Wuebben
7 * wuebben@math.cornell.edu 7 * wuebben@math.cornell.edu
8 * 8 *
9 * based on EzPPP: 9 * based on EzPPP:
10 * Copyright (C) 1997 Jay Painter 10 * Copyright (C) 1997 Jay Painter
11 * 11 *
12 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Library General Public 13 * modify it under the terms of the GNU Library General Public
14 * License as published by the Free Software Foundation; either 14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version. 15 * version 2 of the License, or (at your option) any later version.
16 * 16 *
17 * This program is distributed in the hope that it will be useful, 17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details. 20 * Library General Public License for more details.
21 * 21 *
22 * You should have received a copy of the GNU Library General Public 22 * You should have received a copy of the GNU Library General Public
23 * License along with this program; if not, write to the Free 23 * License along with this program; if not, write to the Free
24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */ 25 */
26 26
27#include "interfaceppp.h" 27#include "interfaceppp.h"
28#include "devices.h" 28#include "devices.h"
29#include "authwidget.h" 29#include "authwidget.h"
30#include "pppdata.h" 30#include "pppdata.h"
31#include "edit.h" 31#include "edit.h"
32#include "general.h" 32#include "general.h"
33 33
34/* OPIE */ 34/* OPIE */
35#include <opie2/odebug.h>
35#include <qpe/qpeapplication.h> 36#include <qpe/qpeapplication.h>
37using namespace Opie::Core;
36 38
37/* QT */ 39/* QT */
38#include <qdir.h> 40#include <qdir.h>
39#include <qlayout.h> 41#include <qlayout.h>
40#include <qtabwidget.h> 42#include <qtabwidget.h>
41#include <qtabdialog.h> 43#include <qtabdialog.h>
42#include <qwhatsthis.h> 44#include <qwhatsthis.h>
43#include <qmessagebox.h> 45#include <qmessagebox.h>
44#include <qapplication.h> 46#include <qapplication.h>
45#include <qbuttongroup.h> 47#include <qbuttongroup.h>
46#include <qmessagebox.h> 48#include <qmessagebox.h>
47#include <qvgroupbox.h> 49#include <qvgroupbox.h>
48 50
49/* STD */ 51/* STD */
50#include <stdlib.h> 52#include <stdlib.h>
51 53
52 54
53void parseargs(char* buf, char** args); 55void parseargs(char* buf, char** args);
54 56
55DevicesWidget::DevicesWidget( InterfacePPP* ip, QWidget *parent, const char *name, WFlags f ) 57DevicesWidget::DevicesWidget( InterfacePPP* ip, QWidget *parent, const char *name, WFlags f )
56 : ChooserWidget(ip->data(), parent, name, f) 58 : ChooserWidget(ip->data(), parent, name, f)
57{ 59{
58 _ifaceppp = ip; 60 _ifaceppp = ip;
59 QWhatsThis::add(edit_b, tr("Allows you to modify the selected device")); 61 QWhatsThis::add(edit_b, tr("Allows you to modify the selected device"));
60 QWhatsThis::add(new_b, tr("Create a new device") ); 62 QWhatsThis::add(new_b, tr("Create a new device") );
61 63
62 QWhatsThis::add(copy_b, 64 QWhatsThis::add(copy_b,
63 tr("Makes a copy of the selected device. All\n" 65 tr("Makes a copy of the selected device. All\n"
64 "settings of the selected device are copied\n" 66 "settings of the selected device are copied\n"
65 "to a new device, that you can modify to fit your\n" 67 "to a new device, that you can modify to fit your\n"
66 "needs")); 68 "needs"));
67 QWhatsThis::add(delete_b, 69 QWhatsThis::add(delete_b,
68 tr("<p>Deletes the selected device\n\n" 70 tr("<p>Deletes the selected device\n\n"
69 "<font color=\"red\"><b>Use with care!</b></font>")); 71 "<font color=\"red\"><b>Use with care!</b></font>"));
70 72
71 copy_b->setEnabled( false ); //FIXME 73 copy_b->setEnabled( false ); //FIXME
72// delete_b->setEnabled( false ); //FIXME 74// delete_b->setEnabled( false ); //FIXME
73 75
74 QStringList tmp = _pppdata->getDevicesNamesList(); 76 QStringList tmp = _pppdata->getDevicesNamesList();
75 odebug << "DevicesWidget::DevicesWidget got devices " << tmp.join("--").latin1() << "" << oendl; 77 odebug << "DevicesWidget::DevicesWidget got devices " << tmp.join("--").latin1() << "" << oendl;
76 listListbox->insertStringList(tmp); 78 listListbox->insertStringList(tmp);
77 79
78 for (uint i = 0; i < listListbox->count(); i++){ 80 for (uint i = 0; i < listListbox->count(); i++){
79 odebug << "listListbox->text(i) " << listListbox->text(i).latin1() << " == _pppdata->devname() " << _pppdata->devname().latin1() << "" << oendl; 81 odebug << "listListbox->text(i) " << listListbox->text(i).latin1() << " == _pppdata->devname() " << _pppdata->devname().latin1() << "" << oendl;
80 if ( listListbox->text(i) == _pppdata->devname() ) 82 if ( listListbox->text(i) == _pppdata->devname() )
81 listListbox->setCurrentItem( i ); 83 listListbox->setCurrentItem( i );
82 } 84 }
83} 85}
84 86
85 87
86 88
87void DevicesWidget::slotListBoxSelect(int idx) { 89void DevicesWidget::slotListBoxSelect(int idx) {
88 bool ok = _pppdata->setDevice( listListbox->text(idx) ); 90 bool ok = _pppdata->setDevice( listListbox->text(idx) );
89 delete_b->setEnabled((bool)(idx != -1)); 91 delete_b->setEnabled((bool)(idx != -1));
90 edit_b->setEnabled((bool)(idx != -1)); 92 edit_b->setEnabled((bool)(idx != -1));
91//FIXME copy_b->setEnabled((bool)(idx != -1)); 93//FIXME copy_b->setEnabled((bool)(idx != -1));
92} 94}
93 95
94void DevicesWidget::edit() { 96void DevicesWidget::edit() {
95 _pppdata->setDevice(listListbox->text(listListbox->currentItem())); 97 _pppdata->setDevice(listListbox->text(listListbox->currentItem()));
96 98
97 int result = doTab(); 99 int result = doTab();
98 100
99 if(result == QDialog::Accepted) { 101 if(result == QDialog::Accepted) {
100 listListbox->changeItem(_pppdata->devname(),listListbox->currentItem()); 102 listListbox->changeItem(_pppdata->devname(),listListbox->currentItem());
101 _pppdata->save(); 103 _pppdata->save();
102 } 104 }
103} 105}
104 106
105 107
106void DevicesWidget::create() { 108void DevicesWidget::create() {
107 109
108// if(listListbox->count() == MAX_ACCOUNTS) { 110// if(listListbox->count() == MAX_ACCOUNTS) {
109// QMessageBox::information(this, "sorry", 111// QMessageBox::information(this, "sorry",
110// tr("Maximum number of accounts reached.")); 112// tr("Maximum number of accounts reached."));
111// return; 113// return;
112// } 114// }
113 115
114 int result; 116 int result;
115 if (_pppdata->newdevice() == -1){ 117 if (_pppdata->newdevice() == -1){
116 return; 118 return;
117 } 119 }
118 result = doTab(); 120 result = doTab();
119 121
120 if(result == QDialog::Accepted) { 122 if(result == QDialog::Accepted) {
121 listListbox->insertItem(_pppdata->devname()); 123 listListbox->insertItem(_pppdata->devname());
122 listListbox->setSelected(listListbox->findItem(_pppdata->devname()),true ); 124 listListbox->setSelected(listListbox->findItem(_pppdata->devname()),true );
123 125
124 _pppdata->save(); 126 _pppdata->save();
125 } else 127 } else
126 _pppdata->deleteDevice(); 128 _pppdata->deleteDevice();
127} 129}
128 130
129 131
130void DevicesWidget::copy() { 132void DevicesWidget::copy() {
131// if(listListbox->count() == MAX_ACCOUNTS) { 133// if(listListbox->count() == MAX_ACCOUNTS) {
132// QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached.")); 134// QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached."));
133// return; 135// return;
134// } 136// }
135 137
136 if(listListbox->currentItem()<0) { 138 if(listListbox->currentItem()<0) {
137 QMessageBox::information(this, "sorry", tr("No devices selected.")); 139 QMessageBox::information(this, "sorry", tr("No devices selected."));
138 return; 140 return;
139 } 141 }
140 142
141 _pppdata->copydevice(listListbox->currentText()); 143 _pppdata->copydevice(listListbox->currentText());
142 144
143 listListbox->insertItem(_pppdata->devname()); 145 listListbox->insertItem(_pppdata->devname());
144 _pppdata->save(); 146 _pppdata->save();
145} 147}
146 148
147 149
148void DevicesWidget::remove() { 150void DevicesWidget::remove() {
149 151
150 QString s = tr("Are you sure you want to delete\nthe device \"%1\"?") 152 QString s = tr("Are you sure you want to delete\nthe device \"%1\"?")
151 .arg(listListbox->text(listListbox->currentItem())); 153 .arg(listListbox->text(listListbox->currentItem()));
152 154
153 if(QMessageBox::warning(this,tr("Confirm"),s, 155 if(QMessageBox::warning(this,tr("Confirm"),s,
154 QMessageBox::Yes,QMessageBox::No 156 QMessageBox::Yes,QMessageBox::No
155 ) != QMessageBox::Yes) 157 ) != QMessageBox::Yes)
156 return; 158 return;
157 159
158 if(_pppdata->deleteDevice(listListbox->text(listListbox->currentItem()))) 160 if(_pppdata->deleteDevice(listListbox->text(listListbox->currentItem())))
159 listListbox->removeItem(listListbox->currentItem()); 161 listListbox->removeItem(listListbox->currentItem());
160 162
161 163
162// _pppdata->save(); 164// _pppdata->save();
163 165
164 166
165 slotListBoxSelect(listListbox->currentItem()); 167 slotListBoxSelect(listListbox->currentItem());
166 168
167} 169}
168 170
169 171
170int DevicesWidget::doTab(){ 172int DevicesWidget::doTab(){
171 QDialog *dlg = new QDialog( 0, "newDevice", true, Qt::WStyle_ContextHelp ); 173 QDialog *dlg = new QDialog( 0, "newDevice", true, Qt::WStyle_ContextHelp );
172 QVBoxLayout *layout = new QVBoxLayout( dlg ); 174 QVBoxLayout *layout = new QVBoxLayout( dlg );
173 layout->setSpacing( 0 ); 175 layout->setSpacing( 0 );
174 layout->setMargin( 1 ); 176 layout->setMargin( 1 );
175 177
176 QTabWidget *tabWindow = new QTabWidget( dlg, "tabWindow" ); 178 QTabWidget *tabWindow = new QTabWidget( dlg, "tabWindow" );
177 layout->addWidget( tabWindow ); 179 layout->addWidget( tabWindow );
178 180
179 bool isnew; 181 bool isnew;
180 182
181 if(_pppdata->devname().isEmpty()) { 183 if(_pppdata->devname().isEmpty()) {
182 dlg->setCaption(tr("New Device")); 184 dlg->setCaption(tr("New Device"));
183 isnew = true; 185 isnew = true;
184 } else { 186 } else {
185 QString tit = tr("Edit Device: "); 187 QString tit = tr("Edit Device: ");
186 tit += _pppdata->devname(); 188 tit += _pppdata->devname();
187 dlg->setCaption(tit); 189 dlg->setCaption(tit);
188 isnew = false; 190 isnew = false;
189 } 191 }
190 192
191 modem1 = new ModemWidget( _pppdata, tabWindow, "modem1" ); 193 modem1 = new ModemWidget( _pppdata, tabWindow, "modem1" );
192 tabWindow->addTab( modem1, tr("&Device") ); 194 tabWindow->addTab( modem1, tr("&Device") );
193 modem2 = new ModemWidget2( _pppdata, _ifaceppp, tabWindow, "modem2" ); 195 modem2 = new ModemWidget2( _pppdata, _ifaceppp, tabWindow, "modem2" );
194 tabWindow->addTab( modem2, tr("&Modem") ); 196 tabWindow->addTab( modem2, tr("&Modem") );
195 197
196 int result = 0; 198 int result = 0;
197 bool ok = false; 199 bool ok = false;
198 200
199 while (!ok){ 201 while (!ok){
200 result = QPEApplication::execDialog( dlg ); 202 result = QPEApplication::execDialog( dlg );
201 ok = true; 203 ok = true;
202 204
203 if(result == QDialog::Accepted) { 205 if(result == QDialog::Accepted) {
204 if (!modem1->save()){ 206 if (!modem1->save()){
205 QMessageBox::critical(this, "error", tr( "You must enter a unique device name")); 207 QMessageBox::critical(this, "error", tr( "You must enter a unique device name"));
206 ok = false; 208 ok = false;
207 }else{ 209 }else{
208 modem2->save(); 210 modem2->save();
209 } 211 }
210 } 212 }
211 } 213 }
212 214
213 delete dlg; 215 delete dlg;
214 216
215 return result; 217 return result;
216} 218}
217 219
diff --git a/noncore/settings/networksettings/ppp/general.cpp b/noncore/settings/networksettings/ppp/general.cpp
index 69bb682..40ba19b 100644
--- a/noncore/settings/networksettings/ppp/general.cpp
+++ b/noncore/settings/networksettings/ppp/general.cpp
@@ -1,526 +1,528 @@
1/* 1/*
2 * kPPP: A pppd front end for the KDE project 2 * kPPP: A pppd front end for the KDE project
3 * 3 *
4 * $Id$ 4 * $Id$
5 * 5 *
6 * Copyright (C) 1997 Bernd Johannes Wuebben 6 * Copyright (C) 1997 Bernd Johannes Wuebben
7 * wuebben@math.cornell.edu 7 * wuebben@math.cornell.edu
8 * 8 *
9 * based on EzPPP: 9 * based on EzPPP:
10 * Copyright (C) 1997 Jay Painter 10 * Copyright (C) 1997 Jay Painter
11 * 11 *
12 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Library General Public 13 * modify it under the terms of the GNU Library General Public
14 * License as published by the Free Software Foundation; either 14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version. 15 * version 2 of the License, or (at your option) any later version.
16 * 16 *
17 * This program is distributed in the hope that it will be useful, 17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details. 20 * Library General Public License for more details.
21 * 21 *
22 * You should have received a copy of the GNU Library General Public 22 * You should have received a copy of the GNU Library General Public
23 * License along with this program; if not, write to the Free 23 * License along with this program; if not, write to the Free
24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */ 25 */
26 26
27#include "general.h" 27#include "general.h"
28#include "interfaceppp.h" 28#include "interfaceppp.h"
29#include "modeminfo.h" 29#include "modeminfo.h"
30#include "modemcmds.h" 30#include "modemcmds.h"
31#include "pppdata.h" 31#include "pppdata.h"
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/odebug.h>
34#include <qpe/config.h> 35#include <qpe/config.h>
35#include <qpe/qpeapplication.h> 36#include <qpe/qpeapplication.h>
37using namespace Opie::Core;
36 38
37/* QT */ 39/* QT */
38#include <qcheckbox.h> 40#include <qcheckbox.h>
39#include <qcombobox.h> 41#include <qcombobox.h>
40#include <qlabel.h> 42#include <qlabel.h>
41#include <qlayout.h> 43#include <qlayout.h>
42#include <qpushbutton.h> 44#include <qpushbutton.h>
43#include <qslider.h> 45#include <qslider.h>
44#include <qspinbox.h> 46#include <qspinbox.h>
45#include <qwhatsthis.h> 47#include <qwhatsthis.h>
46 48
47/* STD */ 49/* STD */
48#include <termios.h> 50#include <termios.h>
49#include <string.h> 51#include <string.h>
50 52
51 53
52ModemWidget::ModemWidget( PPPData *pd, QWidget *parent, const char *name ) 54ModemWidget::ModemWidget( PPPData *pd, QWidget *parent, const char *name )
53 : QWidget(parent, name), _pppdata(pd) 55 : QWidget(parent, name), _pppdata(pd)
54{ 56{
55 int k; 57 int k;
56 58
57 QGridLayout *tl = new QGridLayout(this, 8, 2, 0 );//, KDialog::spacingHint()); 59 QGridLayout *tl = new QGridLayout(this, 8, 2, 0 );//, KDialog::spacingHint());
58 60
59 QLabel *label1; 61 QLabel *label1;
60 62
61 label1 = new QLabel(tr("Modem &name:"), this); 63 label1 = new QLabel(tr("Modem &name:"), this);
62 tl->addWidget(label1, 0, 0); 64 tl->addWidget(label1, 0, 0);
63 65
64 modemname = new QLineEdit(this, "modemName"); 66 modemname = new QLineEdit(this, "modemName");
65 modemname->setText( _pppdata->devname() ); 67 modemname->setText( _pppdata->devname() );
66 label1->setBuddy(modemname); 68 label1->setBuddy(modemname);
67 tl->addWidget(modemname, 0, 1); 69 tl->addWidget(modemname, 0, 1);
68 70
69 label1 = new QLabel(tr("Modem de&vice:"), this); 71 label1 = new QLabel(tr("Modem de&vice:"), this);
70 tl->addWidget(label1, 1, 0); 72 tl->addWidget(label1, 1, 0);
71 73
72 modemdevice = new QComboBox(false, this); 74 modemdevice = new QComboBox(false, this);
73 modemdevice->setEditable( true ); 75 modemdevice->setEditable( true );
74 modemdevice->setDuplicatesEnabled ( false ); 76 modemdevice->setDuplicatesEnabled ( false );
75 modemdevice->setInsertionPolicy( QComboBox::AtTop ); 77 modemdevice->setInsertionPolicy( QComboBox::AtTop );
76 label1->setBuddy(modemdevice); 78 label1->setBuddy(modemdevice);
77 79
78 Config cfg("NetworkSetupPPP"); 80 Config cfg("NetworkSetupPPP");
79 cfg.setGroup("Devices_General"); 81 cfg.setGroup("Devices_General");
80 QStringList devs = cfg.readListEntry("devices",','); 82 QStringList devs = cfg.readListEntry("devices",',');
81 if (devs.isEmpty()) devs << "/dev/modem" << "/dev/ircomm0" << "/dev/ttyS0"; 83 if (devs.isEmpty()) devs << "/dev/modem" << "/dev/ircomm0" << "/dev/ttyS0";
82 modemdevice->insertStringList( devs ); 84 modemdevice->insertStringList( devs );
83 tl->addWidget(modemdevice, 1, 1); 85 tl->addWidget(modemdevice, 1, 1);
84 86
85 // connect(modemdevice, SIGNAL(activated(int)), 87 // connect(modemdevice, SIGNAL(activated(int)),
86 // SLOT(setmodemdc(int))); 88 // SLOT(setmodemdc(int)));
87 // connect(modemdevice, SIGNAL(textChanged(const QString&) ), 89 // connect(modemdevice, SIGNAL(textChanged(const QString&) ),
88 // SLOT( setmodemdc(const QString&) ) ); 90 // SLOT( setmodemdc(const QString&) ) );
89 91
90 QString tmp = tr("This specifies the serial port your modem is attached \n" 92 QString tmp = tr("This specifies the serial port your modem is attached \n"
91 "to. On Linux/x86, typically this is either /dev/ttyS0 \n" 93 "to. On Linux/x86, typically this is either /dev/ttyS0 \n"
92 "(COM1 under DOS) or /dev/ttyS1 (COM2 under DOS).\n" 94 "(COM1 under DOS) or /dev/ttyS1 (COM2 under DOS).\n"
93 "\n" 95 "\n"
94 "If you have an internal ISDN card with AT command\n" 96 "If you have an internal ISDN card with AT command\n"
95 "emulation (most cards under Linux support this), you\n" 97 "emulation (most cards under Linux support this), you\n"
96 "should select one of the /dev/ttyIx devices."); 98 "should select one of the /dev/ttyIx devices.");
97 99
98 QWhatsThis::add(label1,tmp); 100 QWhatsThis::add(label1,tmp);
99 QWhatsThis::add(modemdevice,tmp); 101 QWhatsThis::add(modemdevice,tmp);
100 102
101 103
102 label1 = new QLabel(tr("&Flow control:"), this); 104 label1 = new QLabel(tr("&Flow control:"), this);
103 tl->addWidget(label1, 2, 0); 105 tl->addWidget(label1, 2, 0);
104 106
105 flowcontrol = new QComboBox(false, this); 107 flowcontrol = new QComboBox(false, this);
106 label1->setBuddy(flowcontrol); 108 label1->setBuddy(flowcontrol);
107 flowcontrol->insertItem(tr("Hardware [CRTSCTS]")); 109 flowcontrol->insertItem(tr("Hardware [CRTSCTS]"));
108 flowcontrol->insertItem(tr("Software [XON/XOFF]")); 110 flowcontrol->insertItem(tr("Software [XON/XOFF]"));
109 flowcontrol->insertItem(tr("None")); 111 flowcontrol->insertItem(tr("None"));
110 tl->addWidget(flowcontrol, 2, 1); 112 tl->addWidget(flowcontrol, 2, 1);
111 // connect(flowcontrol, SIGNAL(activated(int)), 113 // connect(flowcontrol, SIGNAL(activated(int)),
112 // SLOT(setflowcontrol(int))); 114 // SLOT(setflowcontrol(int)));
113 115
114 tmp = tr("<p>Specifies how the serial port and modem\n" 116 tmp = tr("<p>Specifies how the serial port and modem\n"
115 "communicate. You should not change this unless\n" 117 "communicate. You should not change this unless\n"
116 "you know what you are doing.\n" 118 "you know what you are doing.\n"
117 "\n" 119 "\n"
118 "<b>Default</b>: CRTSCTS"); 120 "<b>Default</b>: CRTSCTS");
119 121
120 QWhatsThis::add(label1,tmp); 122 QWhatsThis::add(label1,tmp);
121 QWhatsThis::add(flowcontrol,tmp); 123 QWhatsThis::add(flowcontrol,tmp);
122 124
123 QLabel *labelenter = new QLabel(tr("&Line termination:"), this); 125 QLabel *labelenter = new QLabel(tr("&Line termination:"), this);
124 tl->addWidget(labelenter, 3, 0); 126 tl->addWidget(labelenter, 3, 0);
125 127
126 enter = new QComboBox(false, this); 128 enter = new QComboBox(false, this);
127 labelenter->setBuddy(enter); 129 labelenter->setBuddy(enter);
128 enter->insertItem("CR"); 130 enter->insertItem("CR");
129 enter->insertItem("LF"); 131 enter->insertItem("LF");
130 enter->insertItem("CR/LF"); 132 enter->insertItem("CR/LF");
131 tl->addWidget(enter, 3, 1); 133 tl->addWidget(enter, 3, 1);
132 // connect(enter, SIGNAL(activated(int)), SLOT(setenter(int))); 134 // connect(enter, SIGNAL(activated(int)), SLOT(setenter(int)));
133 tmp = tr("<p>Specifies how AT commands are sent to your\n" 135 tmp = tr("<p>Specifies how AT commands are sent to your\n"
134 "modem. Most modems will work fine with the\n" 136 "modem. Most modems will work fine with the\n"
135 "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"
136 "to the init string, you should try different\n" 138 "to the init string, you should try different\n"
137 "settings here\n" 139 "settings here\n"
138 "\n" 140 "\n"
139 "<b>Default</b>: CR/LF"); 141 "<b>Default</b>: CR/LF");
140 142
141 QWhatsThis::add(labelenter,tmp); 143 QWhatsThis::add(labelenter,tmp);
142 QWhatsThis::add(enter, tmp); 144 QWhatsThis::add(enter, tmp);
143 145
144 QLabel *baud_label = new QLabel(tr("Co&nnection speed:"), this); 146 QLabel *baud_label = new QLabel(tr("Co&nnection speed:"), this);
145 tl->addWidget(baud_label, 4, 0); 147 tl->addWidget(baud_label, 4, 0);
146 baud_c = new QComboBox(this); 148 baud_c = new QComboBox(this);
147 baud_label->setBuddy(baud_c); 149 baud_label->setBuddy(baud_c);
148 150
149 static const char *baudrates[] = 151 static const char *baudrates[] =
150 { 152 {
151 153
152#ifdef B460800 154#ifdef B460800
153 "460800", 155 "460800",
154#endif 156#endif
155 157
156#ifdef B230400 158#ifdef B230400
157 "230400", 159 "230400",
158#endif 160#endif
159 161
160#ifdef B115200 162#ifdef B115200
161 "115200", 163 "115200",
162#endif 164#endif
163 165
164#ifdef B57600 166#ifdef B57600
165 "57600", 167 "57600",
166#endif 168#endif
167 169
168 "38400", 170 "38400",
169 "19200", 171 "19200",
170 "9600", 172 "9600",
171 "2400", 173 "2400",
172 0 174 0
173 }; 175 };
174 176
175 for(k = 0; baudrates[k]; k++) 177 for(k = 0; baudrates[k]; k++)
176 baud_c->insertItem(baudrates[k]); 178 baud_c->insertItem(baudrates[k]);
177 179
178 baud_c->setCurrentItem(3); 180 baud_c->setCurrentItem(3);
179 // connect(baud_c, SIGNAL(activated(int)), 181 // connect(baud_c, SIGNAL(activated(int)),
180 // this, SLOT(speed_selection(int))); 182 // this, SLOT(speed_selection(int)));
181 tl->addWidget(baud_c, 4, 1); 183 tl->addWidget(baud_c, 4, 1);
182 184
183 tmp = tr("Specifies the speed your modem and the serial\n" 185 tmp = tr("Specifies the speed your modem and the serial\n"
184 "port talk to each other. You should begin with\n" 186 "port talk to each other. You should begin with\n"
185 "the default of 38400 bits/sec. If everything\n" 187 "the default of 38400 bits/sec. If everything\n"
186 "works you can try to increase this value, but to\n" 188 "works you can try to increase this value, but to\n"
187 "no more than 115200 bits/sec (unless you know\n" 189 "no more than 115200 bits/sec (unless you know\n"
188 "that your serial port supports higher speeds)."); 190 "that your serial port supports higher speeds).");
189 191
190 QWhatsThis::add(baud_label,tmp); 192 QWhatsThis::add(baud_label,tmp);
191 QWhatsThis::add(baud_c,tmp); 193 QWhatsThis::add(baud_c,tmp);
192 194
193 for(int i=0; i <= enter->count()-1; i++) 195 for(int i=0; i <= enter->count()-1; i++)
194 { 196 {
195 if(_pppdata->enter() == enter->text(i)) 197 if(_pppdata->enter() == enter->text(i))
196 enter->setCurrentItem(i); 198 enter->setCurrentItem(i);
197 } 199 }
198 200
199 tl->addRowSpacing(5, 10); 201 tl->addRowSpacing(5, 10);
200 202
201 //Modem Lock File 203 //Modem Lock File
202 modemlockfile = new QCheckBox(tr("&Use lock file"), this); 204 modemlockfile = new QCheckBox(tr("&Use lock file"), this);
203 205
204 modemlockfile->setChecked(_pppdata->modemLockFile()); 206 modemlockfile->setChecked(_pppdata->modemLockFile());
205 // connect(modemlockfile, SIGNAL(toggled(bool)), 207 // connect(modemlockfile, SIGNAL(toggled(bool)),
206 // SLOT(modemlockfilechanged(bool))); 208 // SLOT(modemlockfilechanged(bool)));
207 tl->addMultiCellWidget(modemlockfile, 6, 6, 0, 1); 209 tl->addMultiCellWidget(modemlockfile, 6, 6, 0, 1);
208 // l12->addStretch(1); 210 // l12->addStretch(1);
209 QWhatsThis::add(modemlockfile, 211 QWhatsThis::add(modemlockfile,
210 tr("<p>To prevent other programs from accessing the\n" 212 tr("<p>To prevent other programs from accessing the\n"
211 "modem while a connection is established, a\n" 213 "modem while a connection is established, a\n"
212 "file can be created to indicate that the modem\n" 214 "file can be created to indicate that the modem\n"
213 "is in use. On Linux an example file would be\n" 215 "is in use. On Linux an example file would be\n"
214 "<tt>/var/lock/LCK..ttyS1</tt>\n" 216 "<tt>/var/lock/LCK..ttyS1</tt>\n"
215 "Here you can select whether this locking will\n" 217 "Here you can select whether this locking will\n"
216 "be done.\n" 218 "be done.\n"
217 "\n" 219 "\n"
218 "<b>Default</b>: On")); 220 "<b>Default</b>: On"));
219 221
220 // Modem Timeout Line Edit Box 222 // Modem Timeout Line Edit Box
221 QHBoxLayout *timeoutLayout = new QHBoxLayout( this ); 223 QHBoxLayout *timeoutLayout = new QHBoxLayout( this );
222 QLabel *timeoutlabel = new QLabel( tr("Modem timeout:") ,this, "timeout" ); 224 QLabel *timeoutlabel = new QLabel( tr("Modem timeout:") ,this, "timeout" );
223 modemtimeout = new QSpinBox( 1, 120, 1, this, "modemTimeout" ); 225 modemtimeout = new QSpinBox( 1, 120, 1, this, "modemTimeout" );
224 // modemtimeout = new KIntNumInput(_pppdata->modemTimeout(), this); 226 // modemtimeout = new KIntNumInput(_pppdata->modemTimeout(), this);
225 // modemtimeout->setLabel(tr("Modem &timeout:")); 227 // modemtimeout->setLabel(tr("Modem &timeout:"));
226 // modemtimeout->setRange(1, 120, 1); 228 // modemtimeout->setRange(1, 120, 1);
227 modemtimeout->setSuffix(tr(" sec")); 229 modemtimeout->setSuffix(tr(" sec"));
228 modemtimeout->setValue( _pppdata->modemTimeout() ); 230 modemtimeout->setValue( _pppdata->modemTimeout() );
229 // connect(modemtimeout, SIGNAL(valueChanged(int)), 231 // connect(modemtimeout, SIGNAL(valueChanged(int)),
230 // SLOT(modemtimeoutchanged(int))); 232 // SLOT(modemtimeoutchanged(int)));
231 timeoutLayout->addWidget(timeoutlabel); 233 timeoutLayout->addWidget(timeoutlabel);
232 timeoutLayout->addWidget(modemtimeout); 234 timeoutLayout->addWidget(modemtimeout);
233 tl->addMultiCellLayout(timeoutLayout, 7, 7, 0, 1); 235 tl->addMultiCellLayout(timeoutLayout, 7, 7, 0, 1);
234 236
235 QWhatsThis::add(modemtimeout, 237 QWhatsThis::add(modemtimeout,
236 tr("This specifies how long <i>kppp</i> waits for a\n" 238 tr("This specifies how long <i>kppp</i> waits for a\n"
237 "<i>CONNECT</i> response from your modem. The\n" 239 "<i>CONNECT</i> response from your modem. The\n"
238 "recommended value is 30 seconds.")); 240 "recommended value is 30 seconds."));
239 241
240 //set stuff from gpppdata 242 //set stuff from gpppdata
241 for(int i=0; i <= enter->count()-1; i++) 243 for(int i=0; i <= enter->count()-1; i++)
242 { 244 {
243 if(_pppdata->enter() == enter->text(i)) 245 if(_pppdata->enter() == enter->text(i))
244 enter->setCurrentItem(i); 246 enter->setCurrentItem(i);
245 } 247 }
246 248
247 for(int i=0; i <= modemdevice->count()-1; i++) 249 for(int i=0; i <= modemdevice->count()-1; i++)
248 { 250 {
249 if(_pppdata->modemDevice() == modemdevice->text(i)) 251 if(_pppdata->modemDevice() == modemdevice->text(i))
250 modemdevice->setCurrentItem(i); 252 modemdevice->setCurrentItem(i);
251 } 253 }
252 254
253 for(int i=0; i <= flowcontrol->count()-1; i++) 255 for(int i=0; i <= flowcontrol->count()-1; i++)
254 { 256 {
255 if(_pppdata->flowcontrol() == flowcontrol->text(i)) 257 if(_pppdata->flowcontrol() == flowcontrol->text(i))
256 flowcontrol->setCurrentItem(i); 258 flowcontrol->setCurrentItem(i);
257 } 259 }
258 260
259 //set the modem speed 261 //set the modem speed
260 for(int i=0; i < baud_c->count(); i++) 262 for(int i=0; i < baud_c->count(); i++)
261 if(baud_c->text(i) == _pppdata->speed()) 263 if(baud_c->text(i) == _pppdata->speed())
262 baud_c->setCurrentItem(i); 264 baud_c->setCurrentItem(i);
263 265
264 tl->setRowStretch(1, 1); 266 tl->setRowStretch(1, 1);
265} 267}
266 268
267ModemWidget::~ModemWidget() 269ModemWidget::~ModemWidget()
268{ 270{
269 QStringList devs; 271 QStringList devs;
270 272
271 for (int i=0;i<modemdevice->count();i++) 273 for (int i=0;i<modemdevice->count();i++)
272 { 274 {
273 QString s = modemdevice->text(i); 275 QString s = modemdevice->text(i);
274 s.simplifyWhiteSpace(); 276 s.simplifyWhiteSpace();
275 if (! s.isEmpty() ) devs << s; 277 if (! s.isEmpty() ) devs << s;
276 } 278 }
277 279
278 280
279 QString edited = modemdevice->currentText(); 281 QString edited = modemdevice->currentText();
280 if ( !( edited ).isEmpty() ) 282 if ( !( edited ).isEmpty() )
281 { 283 {
282 edited.simplifyWhiteSpace(); 284 edited.simplifyWhiteSpace();
283 if ( devs.contains( edited ) == 0 ) 285 if ( devs.contains( edited ) == 0 )
284 { 286 {
285 devs << edited; 287 devs << edited;
286 } 288 }
287 _pppdata->setModemDevice( edited ); 289 _pppdata->setModemDevice( edited );
288 } 290 }
289 291
290 292
291 Config cfg("NetworkSetupPPP"); 293 Config cfg("NetworkSetupPPP");
292 cfg.setGroup("Devices_General"); 294 cfg.setGroup("Devices_General");
293 cfg.writeEntry("devices",devs,','); 295 cfg.writeEntry("devices",devs,',');
294 296
295} 297}
296 298
297// void ModemWidget::speed_selection(int) { 299// void ModemWidget::speed_selection(int) {
298// _pppdata->setSpeed(baud_c->text(baud_c->currentItem())); 300// _pppdata->setSpeed(baud_c->text(baud_c->currentItem()));
299// } 301// }
300 302
301 303
302// void ModemWidget::setenter(int ) { 304// void ModemWidget::setenter(int ) {
303// _pppdata->setEnter(enter->text(enter->currentItem())); 305// _pppdata->setEnter(enter->text(enter->currentItem()));
304// } 306// }
305 307
306 308
307// void ModemWidget::setmodemdc(int i) { 309// void ModemWidget::setmodemdc(int i) {
308// _pppdata->setModemDevice(modemdevice->text(i)); 310// _pppdata->setModemDevice(modemdevice->text(i));
309// } 311// }
310 312
311// void ModemWidget::setmodemdc( const QString &string ) { 313// void ModemWidget::setmodemdc( const QString &string ) {
312// _pppdata->setModemDevice( string ); 314// _pppdata->setModemDevice( string );
313// } 315// }
314 316
315// void ModemWidget::setflowcontrol(int i) { 317// void ModemWidget::setflowcontrol(int i) {
316// _pppdata->setFlowcontrol(flowcontrol->text(i)); 318// _pppdata->setFlowcontrol(flowcontrol->text(i));
317// } 319// }
318 320
319 321
320// void ModemWidget::modemlockfilechanged(bool set) { 322// void ModemWidget::modemlockfilechanged(bool set) {
321// _pppdata->setModemLockFile(set); 323// _pppdata->setModemLockFile(set);
322// } 324// }
323 325
324 326
325// void ModemWidget::modemtimeoutchanged(int n) { 327// void ModemWidget::modemtimeoutchanged(int n) {
326// _pppdata->setModemTimeout(n); 328// _pppdata->setModemTimeout(n);
327// } 329// }
328 330
329 331
330 332
331bool ModemWidget::save() 333bool ModemWidget::save()
332{ 334{
333 //first check to make sure that the device name is unique! 335 //first check to make sure that the device name is unique!
334 if(modemname->text().isEmpty() || 336 if(modemname->text().isEmpty() ||
335 !_pppdata->isUniqueDevname(modemname->text())) 337 !_pppdata->isUniqueDevname(modemname->text()))
336 return false; 338 return false;
337 339
338 odebug << "ModemWidget::save saving modem1 data" << oendl; 340 odebug << "ModemWidget::save saving modem1 data" << oendl;
339 _pppdata->setDevname( modemname->text() ); 341 _pppdata->setDevname( modemname->text() );
340 _pppdata->setModemDevice( modemdevice->currentText() ); 342 _pppdata->setModemDevice( modemdevice->currentText() );
341 _pppdata->setFlowcontrol(flowcontrol->currentText()); 343 _pppdata->setFlowcontrol(flowcontrol->currentText());
342 _pppdata->setFlowcontrol(flowcontrol->currentText()); 344 _pppdata->setFlowcontrol(flowcontrol->currentText());
343 _pppdata->setSpeed(baud_c->currentText()); 345 _pppdata->setSpeed(baud_c->currentText());
344 _pppdata->setModemLockFile( modemlockfile->isChecked()); 346 _pppdata->setModemLockFile( modemlockfile->isChecked());
345 _pppdata->setModemTimeout( modemtimeout->value() ); 347 _pppdata->setModemTimeout( modemtimeout->value() );
346 return true; 348 return true;
347 349
348} 350}
349 351
350ModemWidget2::ModemWidget2( PPPData *pd, InterfacePPP *ip, QWidget *parent, 352ModemWidget2::ModemWidget2( PPPData *pd, InterfacePPP *ip, QWidget *parent,
351 const char *name) 353 const char *name)
352 : QWidget(parent, name), _pppdata(pd), _ifaceppp(ip) 354 : QWidget(parent, name), _pppdata(pd), _ifaceppp(ip)
353{ 355{
354 QVBoxLayout *l1 = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); 356 QVBoxLayout *l1 = new QVBoxLayout(this, 0 );//, KDialog::spacingHint());
355 357
356 358
357 waitfordt = new QCheckBox(tr("&Wait for dial tone before dialing"), this); 359 waitfordt = new QCheckBox(tr("&Wait for dial tone before dialing"), this);
358 waitfordt->setChecked(_pppdata->waitForDialTone()); 360 waitfordt->setChecked(_pppdata->waitForDialTone());
359 // connect(waitfordt, SIGNAL(toggled(bool)), SLOT(waitfordtchanged(bool))); 361 // connect(waitfordt, SIGNAL(toggled(bool)), SLOT(waitfordtchanged(bool)));
360 l1->addWidget(waitfordt); 362 l1->addWidget(waitfordt);
361 QWhatsThis::add(waitfordt, 363 QWhatsThis::add(waitfordt,
362 tr("<p>Normally the modem waits for a dial tone\n" 364 tr("<p>Normally the modem waits for a dial tone\n"
363 "from your phone line, indicating that it can\n" 365 "from your phone line, indicating that it can\n"
364 "start to dial a number. If your modem does not\n" 366 "start to dial a number. If your modem does not\n"
365 "recognize this sound, or your local phone system\n" 367 "recognize this sound, or your local phone system\n"
366 "does not emit such a tone, uncheck this option\n" 368 "does not emit such a tone, uncheck this option\n"
367 "\n" 369 "\n"
368 "<b>Default:</b>: On")); 370 "<b>Default:</b>: On"));
369 371
370 QHBoxLayout *waitLayout = new QHBoxLayout( this ); 372 QHBoxLayout *waitLayout = new QHBoxLayout( this );
371 QLabel *waitLabel = new QLabel( tr("Busy wait:"), this, "busyWait" ); 373 QLabel *waitLabel = new QLabel( tr("Busy wait:"), this, "busyWait" );
372 busywait = new QSpinBox( 0, 300, 5, this, "busyWait" ); 374 busywait = new QSpinBox( 0, 300, 5, this, "busyWait" );
373 // busywait = new KIntNumInput(_pppdata->busyWait(), this); 375 // busywait = new KIntNumInput(_pppdata->busyWait(), this);
374 // busywait->setLabel(tr("B&usy wait:")); 376 // busywait->setLabel(tr("B&usy wait:"));
375 // busywait->setRange(0, 300, 5, true); 377 // busywait->setRange(0, 300, 5, true);
376 busywait->setSuffix(tr(" sec")); 378 busywait->setSuffix(tr(" sec"));
377 // connect(busywait, SIGNAL(valueChanged(int)), SLOT(busywaitchanged(int))); 379 // connect(busywait, SIGNAL(valueChanged(int)), SLOT(busywaitchanged(int)));
378 waitLayout->addWidget(waitLabel); 380 waitLayout->addWidget(waitLabel);
379 waitLayout->addWidget(busywait); 381 waitLayout->addWidget(busywait);
380 l1->addLayout( waitLayout ); 382 l1->addLayout( waitLayout );
381 383
382 QWhatsThis::add(busywait, 384 QWhatsThis::add(busywait,
383 tr("Specifies the number of seconds to wait before\n" 385 tr("Specifies the number of seconds to wait before\n"
384 "redial if all dialed numbers are busy. This is\n" 386 "redial if all dialed numbers are busy. This is\n"
385 "necessary because some modems get stuck if the\n" 387 "necessary because some modems get stuck if the\n"
386 "same number is busy too often.\n" 388 "same number is busy too often.\n"
387 "\n" 389 "\n"
388 "The default is 0 seconds, you should not change\n" 390 "The default is 0 seconds, you should not change\n"
389 "this unless you need to.")); 391 "this unless you need to."));
390 392
391 l1->addSpacing(10); 393 l1->addSpacing(10);
392 394
393 QHBoxLayout *hbl = new QHBoxLayout; 395 QHBoxLayout *hbl = new QHBoxLayout;
394 hbl->setSpacing(2);//KDialog::spacingHint()); 396 hbl->setSpacing(2);//KDialog::spacingHint());
395 397
396 QLabel *volumeLabel = new QLabel(tr("Modem &volume:"), this); 398 QLabel *volumeLabel = new QLabel(tr("Modem &volume:"), this);
397 hbl->addWidget(volumeLabel); 399 hbl->addWidget(volumeLabel);
398 volume = new QSlider(0, 2, 1, _pppdata->volume(), 400 volume = new QSlider(0, 2, 1, _pppdata->volume(),
399 QSlider::Horizontal, this); 401 QSlider::Horizontal, this);
400 volumeLabel->setBuddy(volume); 402 volumeLabel->setBuddy(volume);
401 volume->setTickmarks(QSlider::Below); 403 volume->setTickmarks(QSlider::Below);
402 hbl->addWidget(volume); 404 hbl->addWidget(volume);
403 405
404 l1->addLayout(hbl); 406 l1->addLayout(hbl);
405 407
406 // connect(volume, SIGNAL(valueChanged(int)), 408 // connect(volume, SIGNAL(valueChanged(int)),
407 // this, SLOT(volumeChanged(int))); 409 // this, SLOT(volumeChanged(int)));
408 QString tmp = tr("Most modems have a speaker which makes\n" 410 QString tmp = tr("Most modems have a speaker which makes\n"
409 "a lot of noise when dialing. Here you can\n" 411 "a lot of noise when dialing. Here you can\n"
410 "either turn this completely off or select a\n" 412 "either turn this completely off or select a\n"
411 "lower volume.\n" 413 "lower volume.\n"
412 "\n" 414 "\n"
413 "If this does not work for your modem,\n" 415 "If this does not work for your modem,\n"
414 "you must modify the modem volume command."); 416 "you must modify the modem volume command.");
415 417
416 QWhatsThis::add(volumeLabel,tmp); 418 QWhatsThis::add(volumeLabel,tmp);
417 QWhatsThis::add(volume, tmp); 419 QWhatsThis::add(volume, tmp);
418 420
419 l1->addSpacing(20); 421 l1->addSpacing(20);
420 422
421#if 0 423#if 0
422 chkbox1 = new QCheckBox(tr("Modem asserts CD line"), this); 424 chkbox1 = new QCheckBox(tr("Modem asserts CD line"), this);
423 chkbox1->setChecked(_pppdata->UseCDLine()); 425 chkbox1->setChecked(_pppdata->UseCDLine());
424 connect(chkbox1,SIGNAL(toggled(bool)), 426 connect(chkbox1,SIGNAL(toggled(bool)),
425 this,SLOT(use_cdline_toggled(bool))); 427 this,SLOT(use_cdline_toggled(bool)));
426 l12->addWidget(chkbox1); 428 l12->addWidget(chkbox1);
427 l12->addStretch(1); 429 l12->addStretch(1);
428 l1->addStretch(1); 430 l1->addStretch(1);
429 QWhatsThis::add(chkbox1, 431 QWhatsThis::add(chkbox1,
430 tr("This controls how <i>kppp</i> detects that the modem\n" 432 tr("This controls how <i>kppp</i> detects that the modem\n"
431 "is not responding. Unless you are having\n" 433 "is not responding. Unless you are having\n"
432 "problems with this, do not modify this setting.\n" 434 "problems with this, do not modify this setting.\n"
433 "\n" 435 "\n"
434 "<b>Default</b>: Off")); 436 "<b>Default</b>: Off"));
435#endif 437#endif
436 438
437 modemcmds = new QPushButton(tr("Mod&em Commands..."), this); 439 modemcmds = new QPushButton(tr("Mod&em Commands..."), this);
438 QWhatsThis::add(modemcmds, 440 QWhatsThis::add(modemcmds,
439 tr("Allows you to change the AT command for\n" 441 tr("Allows you to change the AT command for\n"
440 "your modem.")); 442 "your modem."));
441 443
442 modeminfo_button = new QPushButton(tr("&Query Modem..."), this); 444 modeminfo_button = new QPushButton(tr("&Query Modem..."), this);
443 QWhatsThis::add(modeminfo_button, 445 QWhatsThis::add(modeminfo_button,
444 tr("Most modems support the ATI command set to\n" 446 tr("Most modems support the ATI command set to\n"
445 "find out vendor and revision of your modem.\n" 447 "find out vendor and revision of your modem.\n"
446 "\n" 448 "\n"
447 "Press this button to query your modem for\n" 449 "Press this button to query your modem for\n"
448 "this information. It can be useful to help\n" 450 "this information. It can be useful to help\n"
449 "you setup the modem")); 451 "you setup the modem"));
450 452
451 // terminal_button = new QPushButton(tr("&Terminal..."), this); 453 // terminal_button = new QPushButton(tr("&Terminal..."), this);
452 // QWhatsThis::add(terminal_button, 454 // QWhatsThis::add(terminal_button,
453 // tr("Opens the built-in terminal program. You\n" 455 // tr("Opens the built-in terminal program. You\n"
454 // "can use this if you want to play around\n" 456 // "can use this if you want to play around\n"
455 // "with your modem's AT command set")); 457 // "with your modem's AT command set"));
456 458
457 QHBoxLayout *hbox = new QHBoxLayout(); 459 QHBoxLayout *hbox = new QHBoxLayout();
458 l1->addLayout(hbox); 460 l1->addLayout(hbox);
459 hbox->addStretch(1); 461 hbox->addStretch(1);
460 QVBoxLayout *vbox = new QVBoxLayout(); 462 QVBoxLayout *vbox = new QVBoxLayout();
461 hbox->addLayout(vbox); 463 hbox->addLayout(vbox);
462 464
463 vbox->addWidget(modemcmds); 465 vbox->addWidget(modemcmds);
464 vbox->addWidget(modeminfo_button); 466 vbox->addWidget(modeminfo_button);
465 // vbox->addWidget(terminal_button); 467 // vbox->addWidget(terminal_button);
466 468
467 hbox->addStretch(1); 469 hbox->addStretch(1);
468 l1->addStretch(1); 470 l1->addStretch(1);
469 471
470 connect(modemcmds, SIGNAL(clicked()), 472 connect(modemcmds, SIGNAL(clicked()),
471 SLOT(modemcmdsbutton())); 473 SLOT(modemcmdsbutton()));
472 connect(modeminfo_button, SIGNAL(clicked()), 474 connect(modeminfo_button, SIGNAL(clicked()),
473 SLOT(query_modem())); 475 SLOT(query_modem()));
474 // connect(terminal_button, SIGNAL(clicked()), 476 // connect(terminal_button, SIGNAL(clicked()),
475 // SLOT(terminal())); 477 // SLOT(terminal()));
476} 478}
477 479
478 480
479void ModemWidget2::modemcmdsbutton() 481void ModemWidget2::modemcmdsbutton()
480{ 482{
481 ModemCommands mc(_ifaceppp->data(), this, "commands" , true, Qt::WStyle_ContextHelp); 483 ModemCommands mc(_ifaceppp->data(), this, "commands" , true, Qt::WStyle_ContextHelp);
482 484
483 QPEApplication::execDialog( &mc ); 485 QPEApplication::execDialog( &mc );
484} 486}
485 487
486 488
487void ModemWidget2::query_modem() 489void ModemWidget2::query_modem()
488{ 490{
489 ModemTransfer mt(_ifaceppp->modem(), this); 491 ModemTransfer mt(_ifaceppp->modem(), this);
490 mt.exec(); 492 mt.exec();
491} 493}
492 494
493 495
494// void ModemWidget2::terminal() { 496// void ModemWidget2::terminal() {
495// MiniTerm terminal(NULL,NULL); 497// MiniTerm terminal(NULL,NULL);
496// terminal.exec(); 498// terminal.exec();
497// } 499// }
498 500
499 501
500// #if 0 502// #if 0
501// void ModemWidget2::use_cdline_toggled(bool on) { 503// void ModemWidget2::use_cdline_toggled(bool on) {
502// _pppdata->setUseCDLine(on); 504// _pppdata->setUseCDLine(on);
503// } 505// }
504// #endif 506// #endif
505 507
506// void ModemWidget2::waitfordtchanged(bool b) { 508// void ModemWidget2::waitfordtchanged(bool b) {
507// _pppdata->setWaitForDialTone((int)b); 509// _pppdata->setWaitForDialTone((int)b);
508// } 510// }
509 511
510// void ModemWidget2::busywaitchanged(int n) { 512// void ModemWidget2::busywaitchanged(int n) {
511// _pppdata->setbusyWait(n); 513// _pppdata->setbusyWait(n);
512// } 514// }
513 515
514 516
515// void ModemWidget2::volumeChanged(int v) { 517// void ModemWidget2::volumeChanged(int v) {
516// _pppdata->setVolume(v); 518// _pppdata->setVolume(v);
517// } 519// }
518 520
519bool ModemWidget2::save() 521bool ModemWidget2::save()
520{ 522{
521 _pppdata->setWaitForDialTone(waitfordt->isChecked()); 523 _pppdata->setWaitForDialTone(waitfordt->isChecked());
522 _pppdata->setbusyWait(busywait->value()); 524 _pppdata->setbusyWait(busywait->value());
523 _pppdata->setVolume(volume->value()); 525 _pppdata->setVolume(volume->value());
524 return true; 526 return true;
525} 527}
526 528
diff --git a/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp b/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp
index 5a76293..4755aed 100644
--- a/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp
+++ b/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp
@@ -1,41 +1,45 @@
1#include "interfaceinformationppp.h" 1#include "interfaceinformationppp.h"
2#include "connect.h"
3#include "conwindow.h"
4
5/* OPIE */
6#include <opie2/odebug.h>
7using namespace Opie::Core;
2 8
9/* QT */
3#include <qpushbutton.h> 10#include <qpushbutton.h>
4#include <qlabel.h> 11#include <qlabel.h>
5#include <qmessagebox.h> 12#include <qmessagebox.h>
6#include <qabstractlayout.h> 13#include <qabstractlayout.h>
7 14
8#include "connect.h"
9#include "conwindow.h"
10
11#ifdef QWS 15#ifdef QWS
12#else 16#else
13 #define showMaximized show 17 #define showMaximized show
14#endif 18#endif
15 19
16/** 20/**
17 * Constructor for the InterfaceInformationImp class. This class pretty much 21 * Constructor for the InterfaceInformationImp class. This class pretty much
18 * just display's information about the interface that is passed to it. 22 * just display's information about the interface that is passed to it.
19 */ 23 */
20InterfaceInformationPPP::InterfaceInformationPPP(QWidget *parent, const char *name, Interface *i, WFlags f) 24InterfaceInformationPPP::InterfaceInformationPPP(QWidget *parent, const char *name, Interface *i, WFlags f)
21 :InterfaceInformationImp(parent, name, i, Qt::WStyle_ContextHelp) 25 :InterfaceInformationImp(parent, name, i, Qt::WStyle_ContextHelp)
22{ 26{
23 odebug << "InterfaceInformationPPP::InterfaceInformationPPP " << name << "" << oendl; 27 odebug << "InterfaceInformationPPP::InterfaceInformationPPP " << name << "" << oendl;
24 con = new ConnectWidget( (InterfacePPP*)i, this, "con" ); 28 con = new ConnectWidget( (InterfacePPP*)i, this, "con" );
25 con->setSizePolicy( QSizePolicy(QSizePolicy::MinimumExpanding, 29 con->setSizePolicy( QSizePolicy(QSizePolicy::MinimumExpanding,
26 QSizePolicy::Fixed) ); 30 QSizePolicy::Fixed) );
27 31
28 macAddressLabel->hide(); 32 macAddressLabel->hide();
29 subnetMaskLabel->hide(); 33 subnetMaskLabel->hide();
30 broadcastLabel->hide(); 34 broadcastLabel->hide();
31 TextLabel23->hide(); 35 TextLabel23->hide();
32 TextLabel21->hide(); 36 TextLabel21->hide();
33 TextLabel24->hide(); 37 TextLabel24->hide();
34 38
35 InterfaceInformationLayout->addWidget( con, 1, 0 ); 39 InterfaceInformationLayout->addWidget( con, 1, 0 );
36 connect(i, SIGNAL(begin_connect()),con, SLOT(preinit())); 40 connect(i, SIGNAL(begin_connect()),con, SLOT(preinit()));
37 connect(i, SIGNAL(hangup_now() ), con, SLOT(cancelbutton() ) ); 41 connect(i, SIGNAL(hangup_now() ), con, SLOT(cancelbutton() ) );
38} 42}
39 43
40 44
41 45
diff --git a/noncore/settings/networksettings/ppp/interfaceppp.cpp b/noncore/settings/networksettings/ppp/interfaceppp.cpp
index 5cc6f70..7d52f66 100644
--- a/noncore/settings/networksettings/ppp/interfaceppp.cpp
+++ b/noncore/settings/networksettings/ppp/interfaceppp.cpp
@@ -1,174 +1,178 @@
1#include "auth.h"
2#include "interfaceppp.h"
3#include "modem.h"
4#include "pppdata.h"
5
6/* OPIE */
7#include <opie2/odebug.h>
8using namespace Opie::Core;
1 9
10/* QT */
2#include <qmessagebox.h> 11#include <qmessagebox.h>
3#include <qlayout.h> 12#include <qlayout.h>
4#include <qlineedit.h> 13#include <qlineedit.h>
5#include <qlabel.h> 14#include <qlabel.h>
6 15
7#include "auth.h"
8#include "interfaceppp.h"
9#include "modem.h"
10#include "pppdata.h"
11
12InterfacePPP::InterfacePPP(QObject *parent, const char *name, bool status) 16InterfacePPP::InterfacePPP(QObject *parent, const char *name, bool status)
13 : Interface(parent, name, status), 17 : Interface(parent, name, status),
14 _modemPtr(0), 18 _modemPtr(0),
15 _dataPtr(0) 19 _dataPtr(0)
16{ 20{
17 odebug << "InterfacePPP::InterfacePPP(" << oendl; 21 odebug << "InterfacePPP::InterfacePPP(" << oendl;
18} 22}
19 23
20PPPData* InterfacePPP::data()const 24PPPData* InterfacePPP::data()const
21{ 25{
22 if (!_dataPtr){ 26 if (!_dataPtr){
23 odebug << "creating new Data obj" << oendl; 27 odebug << "creating new Data obj" << oendl;
24 _dataPtr = new PPPData(); 28 _dataPtr = new PPPData();
25 _dataPtr->setDevice( getInterfaceName() ); 29 _dataPtr->setDevice( getInterfaceName() );
26 _dataPtr->setAccount( getHardwareName() ); 30 _dataPtr->setAccount( getHardwareName() );
27 } 31 }
28 return _dataPtr; 32 return _dataPtr;
29} 33}
30 34
31Modem* InterfacePPP::modem()const 35Modem* InterfacePPP::modem()const
32{ 36{
33 if (!_modemPtr){ 37 if (!_modemPtr){
34 odebug << "creating new modem obj" << oendl; 38 odebug << "creating new modem obj" << oendl;
35 _modemPtr = new Modem( data() ); 39 _modemPtr = new Modem( data() );
36 } 40 }
37 return _modemPtr; 41 return _modemPtr;
38} 42}
39 43
40bool InterfacePPP::refresh() 44bool InterfacePPP::refresh()
41{ 45{
42 odebug << "InterfacePPP::refresh()" << oendl; 46 odebug << "InterfacePPP::refresh()" << oendl;
43 QString old = getInterfaceName(); 47 QString old = getInterfaceName();
44 setInterfaceName( modem()->pppDevice() ); 48 setInterfaceName( modem()->pppDevice() );
45 49
46 (void)Interface::refresh(); 50 (void)Interface::refresh();
47 51
48 setInterfaceName( old ); 52 setInterfaceName( old );
49 emit updateInterface(this); 53 emit updateInterface(this);
50 54
51 return true; 55 return true;
52} 56}
53 57
54void InterfacePPP::start() 58void InterfacePPP::start()
55{ 59{
56 odebug << "InterfacePPP::start" << oendl; 60 odebug << "InterfacePPP::start" << oendl;
57 61
58 if (data()->password().isEmpty() && !data()->storedUsername().isEmpty() ) { 62 if (data()->password().isEmpty() && !data()->storedUsername().isEmpty() ) {
59 63
60 QDialog mb( 0, "Dialog", true ); 64 QDialog mb( 0, "Dialog", true );
61 mb.setCaption( tr( "No password" ) ); 65 mb.setCaption( tr( "No password" ) );
62 QVBoxLayout layout( &mb ); 66 QVBoxLayout layout( &mb );
63 QLabel text ( &mb ); 67 QLabel text ( &mb );
64 text.setText( tr("Username defined but no password\n Please enter a password") ); 68 text.setText( tr("Username defined but no password\n Please enter a password") );
65 QLineEdit lineedit( &mb ); 69 QLineEdit lineedit( &mb );
66 lineedit.setEchoMode( QLineEdit::Password ); 70 lineedit.setEchoMode( QLineEdit::Password );
67 layout.addWidget( &text ); 71 layout.addWidget( &text );
68 layout.addWidget( &lineedit ); 72 layout.addWidget( &lineedit );
69 if ( mb.exec() == QDialog::Accepted ) { 73 if ( mb.exec() == QDialog::Accepted ) {
70 data()->setPassword( lineedit.text() ); 74 data()->setPassword( lineedit.text() );
71 } 75 }
72 } 76 }
73 77
74 QFileInfo info(pppdPath()); 78 QFileInfo info(pppdPath());
75 79
76 if(!info.exists()){ 80 if(!info.exists()){
77 QMessageBox::warning(0, tr("Error"), 81 QMessageBox::warning(0, tr("Error"),
78 QObject::tr("<qt>Cannot find the PPP daemon!<br>" 82 QObject::tr("<qt>Cannot find the PPP daemon!<br>"
79 "Make sure that pppd is installed and " 83 "Make sure that pppd is installed and "
80 "that you have entered the correct path.</qt>")); 84 "that you have entered the correct path.</qt>"));
81 return; 85 return;
82 } 86 }
83//#if 0 87//#if 0
84 if(!info.isExecutable()){ 88 if(!info.isExecutable()){
85 89
86 QString string; 90 QString string;
87 string = QObject::tr( "<qt>Cannot execute:<br> %1<br>" 91 string = QObject::tr( "<qt>Cannot execute:<br> %1<br>"
88 "Please make sure that you have given " 92 "Please make sure that you have given "
89 "setuid permission and that " 93 "setuid permission and that "
90 "pppd is executable.<br>").arg(pppdPath()); 94 "pppd is executable.<br>").arg(pppdPath());
91 QMessageBox::warning(0, tr("Error"), string); 95 QMessageBox::warning(0, tr("Error"), string);
92 return; 96 return;
93 97
94 } 98 }
95//#endif 99//#endif
96 100
97 QFileInfo info2(data()->modemDevice()); 101 QFileInfo info2(data()->modemDevice());
98 102
99 if(!info2.exists()){ 103 if(!info2.exists()){
100 QString string; 104 QString string;
101 string = QObject::tr( "<qt>Cannot find:<br> %1<br>" 105 string = QObject::tr( "<qt>Cannot find:<br> %1<br>"
102 "Please make sure you have setup " 106 "Please make sure you have setup "
103 "your modem device properly " 107 "your modem device properly "
104 "and/or adjust the location of the modem device on " 108 "and/or adjust the location of the modem device on "
105 "the modem tab of " 109 "the modem tab of "
106 "the setup dialog.</qt>").arg(data()->modemDevice()); 110 "the setup dialog.</qt>").arg(data()->modemDevice());
107 QMessageBox::warning(0, tr("Error"), string); 111 QMessageBox::warning(0, tr("Error"), string);
108 return; 112 return;
109 } 113 }
110 114
111 // if this is a PAP or CHAP account, ensure that username is 115 // if this is a PAP or CHAP account, ensure that username is
112 // supplied 116 // supplied
113 if(data()->authMethod() == AUTH_PAP || 117 if(data()->authMethod() == AUTH_PAP ||
114 data()->authMethod() == AUTH_CHAP || 118 data()->authMethod() == AUTH_CHAP ||
115 data()->authMethod() == AUTH_PAPCHAP ) { 119 data()->authMethod() == AUTH_PAPCHAP ) {
116 if(false){ //FIXME: ID_Edit->text().isEmpty()) { 120 if(false){ //FIXME: ID_Edit->text().isEmpty()) {
117 QMessageBox::warning(0,tr("Error"), 121 QMessageBox::warning(0,tr("Error"),
118 QObject::tr("<qt>You have selected the authentication method PAP or CHAP. This requires that you supply a username and a password!</qt>")); 122 QObject::tr("<qt>You have selected the authentication method PAP or CHAP. This requires that you supply a username and a password!</qt>"));
119// FIXME: return; 123// FIXME: return;
120 } else { 124 } else {
121 if(!modem()->setSecret(data()->authMethod(), 125 if(!modem()->setSecret(data()->authMethod(),
122 PPPData::encodeWord(data()->storedUsername()), 126 PPPData::encodeWord(data()->storedUsername()),
123 PPPData::encodeWord(data()->password())) 127 PPPData::encodeWord(data()->password()))
124 ) { 128 ) {
125 QString s; 129 QString s;
126 s = QObject::tr("<qt>Cannot create PAP/CHAP authentication<br>" 130 s = QObject::tr("<qt>Cannot create PAP/CHAP authentication<br>"
127 "file \"%1\"</qt>").arg(PAP_AUTH_FILE); 131 "file \"%1\"</qt>").arg(PAP_AUTH_FILE);
128 QMessageBox::warning(0, tr("Error"), s); 132 QMessageBox::warning(0, tr("Error"), s);
129 return; 133 return;
130 } 134 }
131 } 135 }
132 } 136 }
133 137
134 if (data()->phonenumber().isEmpty()) { 138 if (data()->phonenumber().isEmpty()) {
135 QString s = QObject::tr("You must specify a telephone number!"); 139 QString s = QObject::tr("You must specify a telephone number!");
136 QMessageBox::warning(0, tr("Error"), s); 140 QMessageBox::warning(0, tr("Error"), s);
137 return; 141 return;
138 } 142 }
139 143
140 // SEGFAULTS: 144 // SEGFAULTS:
141// setStatus( true ); 145// setStatus( true );
142// emit updateInterface((Interface*) this); 146// emit updateInterface((Interface*) this);
143 147
144 emit begin_connect(); 148 emit begin_connect();
145 149
146 odebug << "InterfacePPP::start END" << oendl; 150 odebug << "InterfacePPP::start END" << oendl;
147} 151}
148 152
149void InterfacePPP::stop() 153void InterfacePPP::stop()
150{ 154{
151 odebug << "InterfacePPP::stop" << oendl; 155 odebug << "InterfacePPP::stop" << oendl;
152 // emit hangup_now(); 156 // emit hangup_now();
153 status = false; // not connected 157 status = false; // not connected
154 setStatus( false ); 158 setStatus( false );
155 emit hangup_now(); 159 emit hangup_now();
156 refresh(); 160 refresh();
157 161
158} 162}
159 163
160void InterfacePPP::save() 164void InterfacePPP::save()
161{ 165{
162 data()->save(); 166 data()->save();
163 emit updateInterface((Interface*) this); 167 emit updateInterface((Interface*) this);
164} 168}
165QString InterfacePPP::pppDev()const { 169QString InterfacePPP::pppDev()const {
166 return modem()->pppDevice(); 170 return modem()->pppDevice();
167} 171}
168pid_t InterfacePPP::pppPID()const{ 172pid_t InterfacePPP::pppPID()const{
169 return modem()->pppPID(); 173 return modem()->pppPID();
170} 174}
171void InterfacePPP::setPPPDpid( pid_t pid) { 175void InterfacePPP::setPPPDpid( pid_t pid) {
172 setStatus( true ); 176 setStatus( true );
173 modem()->setPPPDPid( pid ); 177 modem()->setPPPDPid( pid );
174} 178}
diff --git a/noncore/settings/networksettings/ppp/modem.cpp b/noncore/settings/networksettings/ppp/modem.cpp
index f3f2639..5913a22 100644
--- a/noncore/settings/networksettings/ppp/modem.cpp
+++ b/noncore/settings/networksettings/ppp/modem.cpp
@@ -1,1080 +1,1085 @@
1/* 1/*
2 * kPPP: A pppd Front End for the KDE project 2 * kPPP: A pppd Front End for the KDE project
3 * 3 *
4 * $Id$ 4 * $Id$
5 * 5 *
6 * Copyright (C) 1997 Bernd Johannes Wuebben 6 * Copyright (C) 1997 Bernd Johannes Wuebben
7 * wuebben@math.cornell.edu 7 * wuebben@math.cornell.edu
8 * 8 *
9 * This file was added by Harri Porten <porten@tu-harburg.de> 9 * This file was added by Harri Porten <porten@tu-harburg.de>
10 * 10 *
11 * 11 *
12 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Library General Public 13 * modify it under the terms of the GNU Library General Public
14 * License as published by the Free Software Foundation; either 14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version. 15 * version 2 of the License, or (at your option) any later version.
16 * 16 *
17 * This program is distributed in the hope that it will be useful, 17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details. 20 * Library General Public License for more details.
21 * 21 *
22 * You should have received a copy of the GNU Library General Public 22 * You should have received a copy of the GNU Library General Public
23 * License along with this program; if not, write to the Free 23 * License along with this program; if not, write to the Free
24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */ 25 */
26 26
27/* OPIE */
28#include <opie2/odebug.h>
29using namespace Opie::Core;
30
31/* STD */
27#include <errno.h> 32#include <errno.h>
28#include <stdlib.h> 33#include <stdlib.h>
29#include <unistd.h> 34#include <unistd.h>
30#include <fcntl.h> 35#include <fcntl.h>
31#include <signal.h> 36#include <signal.h>
32#include <sys/ioctl.h> 37#include <sys/ioctl.h>
33#include <sys/types.h> 38#include <sys/types.h>
34#include <sys/stat.h> 39#include <sys/stat.h>
35#include <setjmp.h> 40#include <setjmp.h>
36#include <regex.h> 41#include <regex.h>
37#include <qregexp.h> 42#include <qregexp.h>
38#include <assert.h> 43#include <assert.h>
39#include <string.h> 44#include <string.h>
40 45
41#ifdef HAVE_RESOLV_H 46#ifdef HAVE_RESOLV_H
42# include <arpa/nameser.h> 47# include <arpa/nameser.h>
43# include <resolv.h> 48# include <resolv.h>
44#endif 49#endif
45 50
46#ifndef _PATH_RESCONF 51#ifndef _PATH_RESCONF
47#define _PATH_RESCONF "/etc/resolv.conf" 52#define _PATH_RESCONF "/etc/resolv.conf"
48#endif 53#endif
49 54
50#define strlcpy strcpy 55#define strlcpy strcpy
51#include "auth.h" 56#include "auth.h"
52#include "modem.h" 57#include "modem.h"
53#include "pppdata.h" 58#include "pppdata.h"
54#define qError qDebug 59#define qError qDebug
55 60
56 61
57#define MY_ASSERT(x) if (!(x)) { \ 62#define MY_ASSERT(x) if (!(x)) { \
58 ofatal << "ASSERT: \"" << #x << "\" in " << __FILE__ << " (" << __LINE__ << ")\n" << oendl; \ 63 ofatal << "ASSERT: \"" << #x << "\" in " << __FILE__ << " (" << __LINE__ << ")\n" << oendl; \
59 exit(1); } 64 exit(1); }
60 65
61 66
62static sigjmp_buf jmp_buffer; 67static sigjmp_buf jmp_buffer;
63 68
64//Modem *Modem::modem = 0; 69//Modem *Modem::modem = 0;
65 70
66 71
67const char* pppdPath() { 72const char* pppdPath() {
68 // wasting a few bytes 73 // wasting a few bytes
69 static char buffer[sizeof(PPPDSEARCHPATH)+sizeof(PPPDNAME)]; 74 static char buffer[sizeof(PPPDSEARCHPATH)+sizeof(PPPDNAME)];
70 static char *pppdPath = 0L; 75 static char *pppdPath = 0L;
71 char *p; 76 char *p;
72 77
73 if(pppdPath == 0L) { 78 if(pppdPath == 0L) {
74 const char *c = PPPDSEARCHPATH; 79 const char *c = PPPDSEARCHPATH;
75 while(*c != '\0') { 80 while(*c != '\0') {
76 while(*c == ':') 81 while(*c == ':')
77 c++; 82 c++;
78 p = buffer; 83 p = buffer;
79 while(*c != '\0' && *c != ':') 84 while(*c != '\0' && *c != ':')
80 *p++ = *c++; 85 *p++ = *c++;
81 *p = '\0'; 86 *p = '\0';
82 strcat(p, "/"); 87 strcat(p, "/");
83 strcat(p, PPPDNAME); 88 strcat(p, PPPDNAME);
84 if(access(buffer, F_OK) == 0) 89 if(access(buffer, F_OK) == 0)
85 return (pppdPath = buffer); 90 return (pppdPath = buffer);
86 } 91 }
87 } 92 }
88 93
89 return pppdPath; 94 return pppdPath;
90} 95}
91 96
92 97
93Modem::Modem( PPPData* pd ) 98Modem::Modem( PPPData* pd )
94{ 99{
95 _pppdata = pd; 100 _pppdata = pd;
96 modemfd = -1; 101 modemfd = -1;
97 _pppdExitStatus = -1; 102 _pppdExitStatus = -1;
98 pppdPid = -1; 103 pppdPid = -1;
99 sn = m_modemDebug = 0L; 104 sn = m_modemDebug = 0L;
100 data_mode = false; 105 data_mode = false;
101 modem_is_locked = false; 106 modem_is_locked = false;
102 lockfile[0] = '\0'; 107 lockfile[0] = '\0';
103 device = "/dev/modem"; 108 device = "/dev/modem";
104} 109}
105 110
106 111
107Modem::~Modem() 112Modem::~Modem()
108{ 113{
109} 114}
110 115
111 116
112speed_t Modem::modemspeed() { 117speed_t Modem::modemspeed() {
113 // convert the string modem speed int the gpppdata object to a t_speed type 118 // convert the string modem speed int the gpppdata object to a t_speed type
114 // to set the modem. The constants here should all be ifdef'd because 119 // to set the modem. The constants here should all be ifdef'd because
115 // other systems may not have them 120 // other systems may not have them
116 int i = _pppdata->speed().toInt()/100; 121 int i = _pppdata->speed().toInt()/100;
117 122
118 switch(i) { 123 switch(i) {
119 case 24: 124 case 24:
120 return B2400; 125 return B2400;
121 break; 126 break;
122 case 96: 127 case 96:
123 return B9600; 128 return B9600;
124 break; 129 break;
125 case 192: 130 case 192:
126 return B19200; 131 return B19200;
127 break; 132 break;
128 case 384: 133 case 384:
129 return B38400; 134 return B38400;
130 break; 135 break;
131#ifdef B57600 136#ifdef B57600
132 case 576: 137 case 576:
133 return B57600; 138 return B57600;
134 break; 139 break;
135#endif 140#endif
136 141
137#ifdef B115200 142#ifdef B115200
138 case 1152: 143 case 1152:
139 return B115200; 144 return B115200;
140 break; 145 break;
141#endif 146#endif
142 147
143#ifdef B230400 148#ifdef B230400
144 case 2304: 149 case 2304:
145 return B230400; 150 return B230400;
146 break; 151 break;
147#endif 152#endif
148 153
149#ifdef B460800 154#ifdef B460800
150 case 4608: 155 case 4608:
151 return B460800; 156 return B460800;
152 break; 157 break;
153#endif 158#endif
154 159
155 default: 160 default:
156 return B38400; 161 return B38400;
157 break; 162 break;
158 } 163 }
159} 164}
160 165
161bool Modem::opentty() { 166bool Modem::opentty() {
162 // int flags; 167 // int flags;
163 168
164//begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { 169//begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) {
165 close(modemfd); 170 close(modemfd);
166 device = _pppdata->modemDevice(); 171 device = _pppdata->modemDevice();
167 if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) { 172 if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) {
168 odebug << "error opening modem device !" << oendl; 173 odebug << "error opening modem device !" << oendl;
169 errmsg = QObject::tr("Unable to open modem."); 174 errmsg = QObject::tr("Unable to open modem.");
170 return false; 175 return false;
171 } 176 }
172//bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { 177//bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) {
173//} 178//}
174 179
175#if 0 180#if 0
176 if(_pppdata->UseCDLine()) { 181 if(_pppdata->UseCDLine()) {
177 if(ioctl(modemfd, TIOCMGET, &flags) == -1) { 182 if(ioctl(modemfd, TIOCMGET, &flags) == -1) {
178 errmsg = QObject::tr("Unable to detect state of CD line."); 183 errmsg = QObject::tr("Unable to detect state of CD line.");
179 ::close(modemfd); 184 ::close(modemfd);
180 modemfd = -1; 185 modemfd = -1;
181 return false; 186 return false;
182 } 187 }
183 if ((flags&TIOCM_CD) == 0) { 188 if ((flags&TIOCM_CD) == 0) {
184 errmsg = QObject::tr("The modem is not ready."); 189 errmsg = QObject::tr("The modem is not ready.");
185 ::close(modemfd); 190 ::close(modemfd);
186 modemfd = -1; 191 modemfd = -1;
187 return false; 192 return false;
188 } 193 }
189 } 194 }
190#endif 195#endif
191 196
192 tcdrain (modemfd); 197 tcdrain (modemfd);
193 tcflush (modemfd, TCIOFLUSH); 198 tcflush (modemfd, TCIOFLUSH);
194 199
195 if(tcgetattr(modemfd, &tty) < 0){ 200 if(tcgetattr(modemfd, &tty) < 0){
196 // this helps in some cases 201 // this helps in some cases
197 tcsendbreak(modemfd, 0); 202 tcsendbreak(modemfd, 0);
198 sleep(1); 203 sleep(1);
199 if(tcgetattr(modemfd, &tty) < 0){ 204 if(tcgetattr(modemfd, &tty) < 0){
200 errmsg = QObject::tr("The modem is busy."); 205 errmsg = QObject::tr("The modem is busy.");
201 ::close(modemfd); 206 ::close(modemfd);
202 modemfd = -1; 207 modemfd = -1;
203 return false; 208 return false;
204 } 209 }
205 } 210 }
206 211
207 memset(&initial_tty,'\0',sizeof(initial_tty)); 212 memset(&initial_tty,'\0',sizeof(initial_tty));
208 213
209 initial_tty = tty; 214 initial_tty = tty;
210 215
211 tty.c_cc[VMIN] = 0; // nonblocking 216 tty.c_cc[VMIN] = 0; // nonblocking
212 tty.c_cc[VTIME] = 0; 217 tty.c_cc[VTIME] = 0;
213 tty.c_oflag = 0; 218 tty.c_oflag = 0;
214 tty.c_lflag = 0; 219 tty.c_lflag = 0;
215 220
216 tty.c_cflag &= ~(CSIZE | CSTOPB | PARENB); 221 tty.c_cflag &= ~(CSIZE | CSTOPB | PARENB);
217 tty.c_cflag |= CS8 | CREAD; 222 tty.c_cflag |= CS8 | CREAD;
218 tty.c_cflag |= CLOCAL; // ignore modem status lines 223 tty.c_cflag |= CLOCAL; // ignore modem status lines
219 tty.c_iflag = IGNBRK | IGNPAR /* | ISTRIP */ ; 224 tty.c_iflag = IGNBRK | IGNPAR /* | ISTRIP */ ;
220 tty.c_lflag &= ~ICANON; // non-canonical mode 225 tty.c_lflag &= ~ICANON; // non-canonical mode
221 tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHOKE); 226 tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHOKE);
222 227
223 228
224 if(_pppdata->flowcontrol() != "None") { 229 if(_pppdata->flowcontrol() != "None") {
225 if(_pppdata->flowcontrol() == "CRTSCTS") { 230 if(_pppdata->flowcontrol() == "CRTSCTS") {
226 tty.c_cflag |= CRTSCTS; 231 tty.c_cflag |= CRTSCTS;
227 } 232 }
228 else { 233 else {
229 tty.c_iflag |= IXON | IXOFF; 234 tty.c_iflag |= IXON | IXOFF;
230 tty.c_cc[VSTOP] = 0x13; /* DC3 = XOFF = ^S */ 235 tty.c_cc[VSTOP] = 0x13; /* DC3 = XOFF = ^S */
231 tty.c_cc[VSTART] = 0x11; /* DC1 = XON = ^Q */ 236 tty.c_cc[VSTART] = 0x11; /* DC1 = XON = ^Q */
232 } 237 }
233 } 238 }
234 else { 239 else {
235 tty.c_cflag &= ~CRTSCTS; 240 tty.c_cflag &= ~CRTSCTS;
236 tty.c_iflag &= ~(IXON | IXOFF); 241 tty.c_iflag &= ~(IXON | IXOFF);
237 } 242 }
238 243
239 cfsetospeed(&tty, modemspeed()); 244 cfsetospeed(&tty, modemspeed());
240 cfsetispeed(&tty, modemspeed()); 245 cfsetispeed(&tty, modemspeed());
241 246
242 tcdrain(modemfd); 247 tcdrain(modemfd);
243 248
244 if(tcsetattr(modemfd, TCSANOW, &tty) < 0){ 249 if(tcsetattr(modemfd, TCSANOW, &tty) < 0){
245 errmsg = QObject::tr("The modem is busy."); 250 errmsg = QObject::tr("The modem is busy.");
246 ::close(modemfd); 251 ::close(modemfd);
247 modemfd=-1; 252 modemfd=-1;
248 return false; 253 return false;
249 } 254 }
250 255
251 errmsg = QObject::tr("Modem Ready."); 256 errmsg = QObject::tr("Modem Ready.");
252 return true; 257 return true;
253} 258}
254 259
255 260
256bool Modem::closetty() { 261bool Modem::closetty() {
257 if(modemfd >=0 ) { 262 if(modemfd >=0 ) {
258 stop(); 263 stop();
259 /* discard data not read or transmitted */ 264 /* discard data not read or transmitted */
260 tcflush(modemfd, TCIOFLUSH); 265 tcflush(modemfd, TCIOFLUSH);
261 266
262 if(tcsetattr(modemfd, TCSANOW, &initial_tty) < 0){ 267 if(tcsetattr(modemfd, TCSANOW, &initial_tty) < 0){
263 errmsg = QObject::tr("Can't restore tty settings: tcsetattr()\n"); 268 errmsg = QObject::tr("Can't restore tty settings: tcsetattr()\n");
264 ::close(modemfd); 269 ::close(modemfd);
265 modemfd = -1; 270 modemfd = -1;
266 return false; 271 return false;
267 } 272 }
268 ::close(modemfd); 273 ::close(modemfd);
269 modemfd = -1; 274 modemfd = -1;
270 } 275 }
271 276
272 return true; 277 return true;
273} 278}
274 279
275 280
276void Modem::readtty(int) { 281void Modem::readtty(int) {
277 char buffer[200]; 282 char buffer[200];
278 unsigned char c; 283 unsigned char c;
279 int len; 284 int len;
280 285
281 // read data in chunks of up to 200 bytes 286 // read data in chunks of up to 200 bytes
282 if((len = ::read(modemfd, buffer, 200)) > 0) { 287 if((len = ::read(modemfd, buffer, 200)) > 0) {
283 // split buffer into single characters for further processing 288 // split buffer into single characters for further processing
284 for(int i = 0; i < len; i++) { 289 for(int i = 0; i < len; i++) {
285 c = buffer[i] & 0x7F; 290 c = buffer[i] & 0x7F;
286 emit charWaiting(c); 291 emit charWaiting(c);
287 } 292 }
288 } 293 }
289} 294}
290 295
291 296
292void Modem::notify(const QObject *receiver, const char *member) { 297void Modem::notify(const QObject *receiver, const char *member) {
293 connect(this, SIGNAL(charWaiting(unsigned char)), receiver, member); 298 connect(this, SIGNAL(charWaiting(unsigned char)), receiver, member);
294 startNotifier(); 299 startNotifier();
295} 300}
296 301
297 302
298void Modem::stop() { 303void Modem::stop() {
299 disconnect(SIGNAL(charWaiting(unsigned char))); 304 disconnect(SIGNAL(charWaiting(unsigned char)));
300 stopNotifier(); 305 stopNotifier();
301} 306}
302 307
303 308
304void Modem::startNotifier() { 309void Modem::startNotifier() {
305 if(modemfd >= 0) { 310 if(modemfd >= 0) {
306 if(sn == 0) { 311 if(sn == 0) {
307 sn = new QSocketNotifier(modemfd, QSocketNotifier::Read, this); 312 sn = new QSocketNotifier(modemfd, QSocketNotifier::Read, this);
308 connect(sn, SIGNAL(activated(int)), SLOT(readtty(int))); 313 connect(sn, SIGNAL(activated(int)), SLOT(readtty(int)));
309 odebug << "QSocketNotifier started!" << oendl; 314 odebug << "QSocketNotifier started!" << oendl;
310 } else { 315 } else {
311 odebug << "QSocketNotifier re-enabled!" << oendl; 316 odebug << "QSocketNotifier re-enabled!" << oendl;
312 sn->setEnabled(true); 317 sn->setEnabled(true);
313 } 318 }
314 } 319 }
315} 320}
316 321
317 322
318void Modem::stopNotifier() { 323void Modem::stopNotifier() {
319 if(sn != 0) { 324 if(sn != 0) {
320 sn->setEnabled(false); 325 sn->setEnabled(false);
321 disconnect(sn); 326 disconnect(sn);
322 delete sn; 327 delete sn;
323 sn = 0; 328 sn = 0;
324 odebug << "QSocketNotifier stopped!" << oendl; 329 odebug << "QSocketNotifier stopped!" << oendl;
325 } 330 }
326} 331}
327 332
328 333
329void Modem::flush() { 334void Modem::flush() {
330 char c; 335 char c;
331 while(read(modemfd, &c, 1) == 1); 336 while(read(modemfd, &c, 1) == 1);
332} 337}
333 338
334 339
335bool Modem::writeChar(unsigned char c) { 340bool Modem::writeChar(unsigned char c) {
336 int s; 341 int s;
337 do { 342 do {
338 s = write(modemfd, &c, 1); 343 s = write(modemfd, &c, 1);
339 if (s < 0) { 344 if (s < 0) {
340 oerr << "write() in Modem::writeChar failed" << oendl; 345 oerr << "write() in Modem::writeChar failed" << oendl;
341 return false; 346 return false;
342 } 347 }
343 } while(s == 0); 348 } while(s == 0);
344 349
345 return true; 350 return true;
346} 351}
347 352
348 353
349bool Modem::writeLine(const char *buf) { 354bool Modem::writeLine(const char *buf) {
350 int len = strlen(buf); 355 int len = strlen(buf);
351 char *b = new char[len+2]; 356 char *b = new char[len+2];
352 memcpy(b, buf, len); 357 memcpy(b, buf, len);
353 // different modems seem to need different line terminations 358 // different modems seem to need different line terminations
354 QString term = _pppdata->enter(); 359 QString term = _pppdata->enter();
355 if(term == "LF") 360 if(term == "LF")
356 b[len++]='\n'; 361 b[len++]='\n';
357 else if(term == "CR") 362 else if(term == "CR")
358 b[len++]='\r'; 363 b[len++]='\r';
359 else if(term == "CR/LF") { 364 else if(term == "CR/LF") {
360 b[len++]='\r'; 365 b[len++]='\r';
361 b[len++]='\n'; 366 b[len++]='\n';
362 } 367 }
363 int l = len; 368 int l = len;
364 while(l) { 369 while(l) {
365 int wr = write(modemfd, &b[len-l], l); 370 int wr = write(modemfd, &b[len-l], l);
366 if(wr < 0) { 371 if(wr < 0) {
367 // TODO do something meaningful with the error code (or ignore it 372 // TODO do something meaningful with the error code (or ignore it
368 oerr << "write() in Modem::writeLine failed" << oendl; 373 oerr << "write() in Modem::writeLine failed" << oendl;
369 delete[] b; 374 delete[] b;
370 return false; 375 return false;
371 } 376 }
372 l -= wr; 377 l -= wr;
373 } 378 }
374 delete[] b; 379 delete[] b;
375 return true; 380 return true;
376} 381}
377 382
378 383
379bool Modem::hangup() { 384bool Modem::hangup() {
380 // this should really get the modem to hang up and go into command mode 385 // this should really get the modem to hang up and go into command mode
381 // If anyone sees a fault in the following please let me know, since 386 // If anyone sees a fault in the following please let me know, since
382 // this is probably the most imporant snippet of code in the whole of 387 // this is probably the most imporant snippet of code in the whole of
383 // kppp. If people complain about kppp being stuck, this piece of code 388 // kppp. If people complain about kppp being stuck, this piece of code
384 // is most likely the reason. 389 // is most likely the reason.
385 struct termios temptty; 390 struct termios temptty;
386 391
387 if(modemfd >= 0) { 392 if(modemfd >= 0) {
388 393
389 // is this Escape & HangupStr stuff really necessary ? (Harri) 394 // is this Escape & HangupStr stuff really necessary ? (Harri)
390 395
391 if (data_mode) escape_to_command_mode(); 396 if (data_mode) escape_to_command_mode();
392 397
393 // Then hangup command 398 // Then hangup command
394 writeLine(_pppdata->modemHangupStr().local8Bit()); 399 writeLine(_pppdata->modemHangupStr().local8Bit());
395 400
396 usleep(_pppdata->modemInitDelay() * 10000); // 0.01 - 3.0 sec 401 usleep(_pppdata->modemInitDelay() * 10000); // 0.01 - 3.0 sec
397 402
398#ifndef DEBUG_WO_DIALING 403#ifndef DEBUG_WO_DIALING
399 if (sigsetjmp(jmp_buffer, 1) == 0) { 404 if (sigsetjmp(jmp_buffer, 1) == 0) {
400 // set alarm in case tcsendbreak() hangs 405 // set alarm in case tcsendbreak() hangs
401 signal(SIGALRM, alarm_handler); 406 signal(SIGALRM, alarm_handler);
402 alarm(2); 407 alarm(2);
403 408
404 tcsendbreak(modemfd, 0); 409 tcsendbreak(modemfd, 0);
405 410
406 alarm(0); 411 alarm(0);
407 signal(SIGALRM, SIG_IGN); 412 signal(SIGALRM, SIG_IGN);
408 } else { 413 } else {
409 // we reach this point if the alarm handler got called 414 // we reach this point if the alarm handler got called
410 closetty(); 415 closetty();
411 close(modemfd); 416 close(modemfd);
412 modemfd = -1; 417 modemfd = -1;
413 errmsg = QObject::tr("The modem does not respond."); 418 errmsg = QObject::tr("The modem does not respond.");
414 return false; 419 return false;
415 } 420 }
416 421
417#ifndef __svr4__ // drops DTR but doesn't set it afterwards again. not good for init. 422#ifndef __svr4__ // drops DTR but doesn't set it afterwards again. not good for init.
418 tcgetattr(modemfd, &temptty); 423 tcgetattr(modemfd, &temptty);
419 cfsetospeed(&temptty, B0); 424 cfsetospeed(&temptty, B0);
420 cfsetispeed(&temptty, B0); 425 cfsetispeed(&temptty, B0);
421 tcsetattr(modemfd, TCSAFLUSH, &temptty); 426 tcsetattr(modemfd, TCSAFLUSH, &temptty);
422#else 427#else
423 int modemstat; 428 int modemstat;
424 ioctl(modemfd, TIOCMGET, &modemstat); 429 ioctl(modemfd, TIOCMGET, &modemstat);
425 modemstat &= ~TIOCM_DTR; 430 modemstat &= ~TIOCM_DTR;
426 ioctl(modemfd, TIOCMSET, &modemstat); 431 ioctl(modemfd, TIOCMSET, &modemstat);
427 ioctl(modemfd, TIOCMGET, &modemstat); 432 ioctl(modemfd, TIOCMGET, &modemstat);
428 modemstat |= TIOCM_DTR; 433 modemstat |= TIOCM_DTR;
429 ioctl(modemfd, TIOCMSET, &modemstat); 434 ioctl(modemfd, TIOCMSET, &modemstat);
430#endif 435#endif
431 436
432 usleep(_pppdata->modemInitDelay() * 10000); // 0.01 - 3.0 secs 437 usleep(_pppdata->modemInitDelay() * 10000); // 0.01 - 3.0 secs
433 438
434 cfsetospeed(&temptty, modemspeed()); 439 cfsetospeed(&temptty, modemspeed());
435 cfsetispeed(&temptty, modemspeed()); 440 cfsetispeed(&temptty, modemspeed());
436 tcsetattr(modemfd, TCSAFLUSH, &temptty); 441 tcsetattr(modemfd, TCSAFLUSH, &temptty);
437#endif 442#endif
438 return true; 443 return true;
439 } else 444 } else
440 return false; 445 return false;
441} 446}
442 447
443 448
444void Modem::escape_to_command_mode() { 449void Modem::escape_to_command_mode() {
445 // Send Properly bracketed escape code to put the modem back into command state. 450 // Send Properly bracketed escape code to put the modem back into command state.
446 // A modem will accept AT commands only when it is in command state. 451 // A modem will accept AT commands only when it is in command state.
447 // When a modem sends the host the CONNECT string, that signals 452 // When a modem sends the host the CONNECT string, that signals
448 // that the modem is now in the connect state (no long accepts AT commands.) 453 // that the modem is now in the connect state (no long accepts AT commands.)
449 // Need to send properly timed escape sequence to put modem in command state. 454 // Need to send properly timed escape sequence to put modem in command state.
450 // Escape codes and guard times are controlled by S2 and S12 values. 455 // Escape codes and guard times are controlled by S2 and S12 values.
451 // 456 //
452 tcflush(modemfd, TCIOFLUSH); 457 tcflush(modemfd, TCIOFLUSH);
453 458
454 // +3 because quiet time must be greater than guard time. 459 // +3 because quiet time must be greater than guard time.
455 usleep((_pppdata->modemEscapeGuardTime()+3)*20000); 460 usleep((_pppdata->modemEscapeGuardTime()+3)*20000);
456 QCString tmp = _pppdata->modemEscapeStr().local8Bit(); 461 QCString tmp = _pppdata->modemEscapeStr().local8Bit();
457 write(modemfd, tmp.data(), tmp.length()); 462 write(modemfd, tmp.data(), tmp.length());
458 tcflush(modemfd, TCIOFLUSH); 463 tcflush(modemfd, TCIOFLUSH);
459 usleep((_pppdata->modemEscapeGuardTime()+3)*20000); 464 usleep((_pppdata->modemEscapeGuardTime()+3)*20000);
460 465
461 data_mode = false; 466 data_mode = false;
462} 467}
463 468
464 469
465const QString Modem::modemMessage() { 470const QString Modem::modemMessage() {
466 return errmsg; 471 return errmsg;
467} 472}
468 473
469 474
470QString Modem::parseModemSpeed(const QString &s) { 475QString Modem::parseModemSpeed(const QString &s) {
471 // this is a small (and bad) parser for modem speeds 476 // this is a small (and bad) parser for modem speeds
472 int rx = -1; 477 int rx = -1;
473 int tx = -1; 478 int tx = -1;
474 int i; 479 int i;
475 QString result; 480 QString result;
476 481
477 odebug << "Modem reported result string: " << s.latin1() << "" << oendl; 482 odebug << "Modem reported result string: " << s.latin1() << "" << oendl;
478 483
479 const int RXMAX = 7; 484 const int RXMAX = 7;
480 const int TXMAX = 2; 485 const int TXMAX = 2;
481 QRegExp rrx[RXMAX] = { 486 QRegExp rrx[RXMAX] = {
482 QRegExp("[0-9]+[:/ ]RX", false), 487 QRegExp("[0-9]+[:/ ]RX", false),
483 QRegExp("[0-9]+RX", false), 488 QRegExp("[0-9]+RX", false),
484 QRegExp("[/: -][0-9]+[/: ]", false), 489 QRegExp("[/: -][0-9]+[/: ]", false),
485 QRegExp("[/: -][0-9]+$", false), 490 QRegExp("[/: -][0-9]+$", false),
486 QRegExp("CARRIER [^0-9]*[0-9]+", false), 491 QRegExp("CARRIER [^0-9]*[0-9]+", false),
487 QRegExp("CONNECT [^0-9]*[0-9]+", false), 492 QRegExp("CONNECT [^0-9]*[0-9]+", false),
488 QRegExp("[0-9]+") // panic mode 493 QRegExp("[0-9]+") // panic mode
489 }; 494 };
490 495
491 QRegExp trx[TXMAX] = { 496 QRegExp trx[TXMAX] = {
492 QRegExp("[0-9]+[:/ ]TX", false), 497 QRegExp("[0-9]+[:/ ]TX", false),
493 QRegExp("[0-9]+TX", false) 498 QRegExp("[0-9]+TX", false)
494 }; 499 };
495 500
496 for(i = 0; i < RXMAX; i++) { 501 for(i = 0; i < RXMAX; i++) {
497 int len, idx, result; 502 int len, idx, result;
498 if((idx = rrx[i].match(s,0,&len)) > -1) { 503 if((idx = rrx[i].match(s,0,&len)) > -1) {
499// if((idx = rrx[i].search(s)) > -1) { 504// if((idx = rrx[i].search(s)) > -1) {
500 // len = rrx[i].matchedLength(); 505 // len = rrx[i].matchedLength();
501 506
502 // 507 //
503 // rrx[i] has been matched, idx contains the start of the match 508 // rrx[i] has been matched, idx contains the start of the match
504 // and len contains how long the match is. Extract the match. 509 // and len contains how long the match is. Extract the match.
505 // 510 //
506 QString sub = s.mid(idx, len); 511 QString sub = s.mid(idx, len);
507 512
508 // 513 //
509 // Now extract the digits only from the match, which will 514 // Now extract the digits only from the match, which will
510 // then be converted to an int. 515 // then be converted to an int.
511 // 516 //
512 if ((idx = rrx[RXMAX-1].match( sub,0,&len )) > -1) { 517 if ((idx = rrx[RXMAX-1].match( sub,0,&len )) > -1) {
513// if ((idx = rrx[RXMAX-1].search( sub )) > -1) { 518// if ((idx = rrx[RXMAX-1].search( sub )) > -1) {
514// len = rrx[RXMAX-1].matchedLength(); 519// len = rrx[RXMAX-1].matchedLength();
515 sub = sub.mid(idx, len); 520 sub = sub.mid(idx, len);
516 result = sub.toInt(); 521 result = sub.toInt();
517 if(result > 0) { 522 if(result > 0) {
518 rx = result; 523 rx = result;
519 break; 524 break;
520 } 525 }
521 } 526 }
522 } 527 }
523 } 528 }
524 529
525 for(i = 0; i < TXMAX; i++) { 530 for(i = 0; i < TXMAX; i++) {
526 int len, idx, result; 531 int len, idx, result;
527 if((idx = trx[i].match(s,0,&len)) > -1) { 532 if((idx = trx[i].match(s,0,&len)) > -1) {
528// if((idx = trx[i].search(s)) > -1) { 533// if((idx = trx[i].search(s)) > -1) {
529// len = trx[i].matchedLength(); 534// len = trx[i].matchedLength();
530 535
531 // 536 //
532 // trx[i] has been matched, idx contains the start of the match 537 // trx[i] has been matched, idx contains the start of the match
533 // and len contains how long the match is. Extract the match. 538 // and len contains how long the match is. Extract the match.
534 // 539 //
535 QString sub = s.mid(idx, len); 540 QString sub = s.mid(idx, len);
536 541
537 // 542 //
538 // Now extract the digits only from the match, which will then 543 // Now extract the digits only from the match, which will then
539 // be converted to an int. 544 // be converted to an int.
540 // 545 //
541 if((idx = rrx[RXMAX-1].match(sub,0,&len)) > -1) { 546 if((idx = rrx[RXMAX-1].match(sub,0,&len)) > -1) {
542// if((idx = rrx[RXMAX-1].search(sub)) > -1) { 547// if((idx = rrx[RXMAX-1].search(sub)) > -1) {
543// len = rrx[RXMAX-1].matchedLength(); 548// len = rrx[RXMAX-1].matchedLength();
544 sub = sub.mid(idx, len); 549 sub = sub.mid(idx, len);
545 result = sub.toInt(); 550 result = sub.toInt();
546 if(result > 0) { 551 if(result > 0) {
547 tx = result; 552 tx = result;
548 break; 553 break;
549 } 554 }
550 } 555 }
551 } 556 }
552 } 557 }
553 558
554 if(rx == -1 && tx == -1) 559 if(rx == -1 && tx == -1)
555 result = QObject::tr("Unknown speed"); 560 result = QObject::tr("Unknown speed");
556 else if(tx == -1) 561 else if(tx == -1)
557 result.setNum(rx); 562 result.setNum(rx);
558 else if(rx == -1) // should not happen 563 else if(rx == -1) // should not happen
559 result.setNum(tx); 564 result.setNum(tx);
560 else 565 else
561 result.sprintf("%d/%d", rx, tx); 566 result.sprintf("%d/%d", rx, tx);
562 567
563 odebug << "The parsed result is: " << result.latin1() << "" << oendl; 568 odebug << "The parsed result is: " << result.latin1() << "" << oendl;
564 569
565 return result; 570 return result;
566} 571}
567 572
568 573
569// Lock modem device. Returns 0 on success 1 if the modem is locked and -1 if 574// Lock modem device. Returns 0 on success 1 if the modem is locked and -1 if
570// a lock file can't be created ( permission problem ) 575// a lock file can't be created ( permission problem )
571int Modem::lockdevice() { 576int Modem::lockdevice() {
572 int fd; 577 int fd;
573 char newlock[80]=""; // safe 578 char newlock[80]=""; // safe
574 579
575 if(!_pppdata->modemLockFile()) { 580 if(!_pppdata->modemLockFile()) {
576 odebug << "The user doesn't want a lockfile." << oendl; 581 odebug << "The user doesn't want a lockfile." << oendl;
577 return 0; 582 return 0;
578 } 583 }
579 584
580 if (modem_is_locked) 585 if (modem_is_locked)
581 return 1; 586 return 1;
582 587
583 QString lockfile = LOCK_DIR"/LCK.."; 588 QString lockfile = LOCK_DIR"/LCK..";
584 lockfile += _pppdata->modemDevice().mid(5); // append everything after /dev/ 589 lockfile += _pppdata->modemDevice().mid(5); // append everything after /dev/
585 590
586 if(access(QFile::encodeName(lockfile), F_OK) == 0) { 591 if(access(QFile::encodeName(lockfile), F_OK) == 0) {
587// if ((fd = Requester::rq-> 592// if ((fd = Requester::rq->
588if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) { 593if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) {
589 // Mario: it's not necessary to read more than lets say 32 bytes. If 594 // Mario: it's not necessary to read more than lets say 32 bytes. If
590 // file has more than 32 bytes, skip the rest 595 // file has more than 32 bytes, skip the rest
591 char oldlock[33]; // safe 596 char oldlock[33]; // safe
592 int sz = read(fd, &oldlock, 32); 597 int sz = read(fd, &oldlock, 32);
593 close (fd); 598 close (fd);
594 if (sz <= 0) 599 if (sz <= 0)
595 return 1; 600 return 1;
596 oldlock[sz] = '\0'; 601 oldlock[sz] = '\0';
597 602
598 odebug << "Device is locked by: " << oldlock << "" << oendl; 603 odebug << "Device is locked by: " << oldlock << "" << oendl;
599 604
600 int oldpid; 605 int oldpid;
601 int match = sscanf(oldlock, "%d", &oldpid); 606 int match = sscanf(oldlock, "%d", &oldpid);
602 607
603 // found a pid in lockfile ? 608 // found a pid in lockfile ?
604 if (match < 1 || oldpid <= 0) 609 if (match < 1 || oldpid <= 0)
605 return 1; 610 return 1;
606 611
607 // check if process exists 612 // check if process exists
608 if (kill((pid_t)oldpid, 0) == 0 || errno != ESRCH) 613 if (kill((pid_t)oldpid, 0) == 0 || errno != ESRCH)
609 return 1; 614 return 1;
610 615
611 odebug << "lockfile is stale" << oendl; 616 odebug << "lockfile is stale" << oendl;
612 } 617 }
613 } 618 }
614 619
615 fd = openLockfile(_pppdata->modemDevice(),O_WRONLY|O_TRUNC|O_CREAT); 620 fd = openLockfile(_pppdata->modemDevice(),O_WRONLY|O_TRUNC|O_CREAT);
616 if(fd >= 0) { 621 if(fd >= 0) {
617 sprintf(newlock,"%010d\n", getpid()); 622 sprintf(newlock,"%010d\n", getpid());
618 odebug << "Locking Device: " << newlock << "" << oendl; 623 odebug << "Locking Device: " << newlock << "" << oendl;
619 624
620 write(fd, newlock, strlen(newlock)); 625 write(fd, newlock, strlen(newlock));
621 close(fd); 626 close(fd);
622 modem_is_locked=true; 627 modem_is_locked=true;
623 628
624 return 0; 629 return 0;
625 } 630 }
626 631
627 return -1; 632 return -1;
628 633
629} 634}
630 635
631 636
632// UnLock modem device 637// UnLock modem device
633void Modem::unlockdevice() { 638void Modem::unlockdevice() {
634 if (modem_is_locked) { 639 if (modem_is_locked) {
635 odebug << "UnLocking Modem Device" << oendl; 640 odebug << "UnLocking Modem Device" << oendl;
636 close(modemfd); 641 close(modemfd);
637 modemfd = -1; 642 modemfd = -1;
638 unlink(lockfile); 643 unlink(lockfile);
639 lockfile[0] = '\0'; 644 lockfile[0] = '\0';
640 modem_is_locked=false; 645 modem_is_locked=false;
641 } 646 }
642} 647}
643 648
644int Modem::openLockfile( QString lockfile, int flags) 649int Modem::openLockfile( QString lockfile, int flags)
645{ 650{
646 int fd; 651 int fd;
647 int mode; 652 int mode;
648 flags = O_RDONLY; 653 flags = O_RDONLY;
649 if(flags == O_WRONLY|O_TRUNC|O_CREAT) 654 if(flags == O_WRONLY|O_TRUNC|O_CREAT)
650 mode = 0644; 655 mode = 0644;
651 else 656 else
652 mode = 0; 657 mode = 0;
653 658
654 lockfile = LOCK_DIR; 659 lockfile = LOCK_DIR;
655 lockfile += "/LCK.."; 660 lockfile += "/LCK..";
656 lockfile += device.right( device.length() - device.findRev("/") -1 ); 661 lockfile += device.right( device.length() - device.findRev("/") -1 );
657 odebug << "lockfile >" << lockfile.latin1() << "<" << oendl; 662 odebug << "lockfile >" << lockfile.latin1() << "<" << oendl;
658 // TODO: 663 // TODO:
659 // struct stat st; 664 // struct stat st;
660 // if(stat(lockfile.data(), &st) == -1) { 665 // if(stat(lockfile.data(), &st) == -1) {
661 // if(errno == EBADF) 666 // if(errno == EBADF)
662 // return -1; 667 // return -1;
663 // } else { 668 // } else {
664 // // make sure that this is a regular file 669 // // make sure that this is a regular file
665 // if(!S_ISREG(st.st_mode)) 670 // if(!S_ISREG(st.st_mode))
666 // return -1; 671 // return -1;
667 // } 672 // }
668 if ((fd = open(lockfile, flags, mode)) == -1) { 673 if ((fd = open(lockfile, flags, mode)) == -1) {
669 odebug << "error opening lockfile!" << oendl; 674 odebug << "error opening lockfile!" << oendl;
670 lockfile = QString::null; 675 lockfile = QString::null;
671 fd = open(DEVNULL, O_RDONLY); 676 fd = open(DEVNULL, O_RDONLY);
672 } else 677 } else
673 fchown(fd, 0, 0); 678 fchown(fd, 0, 0);
674 return fd; 679 return fd;
675} 680}
676 681
677 682
678 683
679void alarm_handler(int) { 684void alarm_handler(int) {
680 // fprintf(stderr, "alarm_handler(): Received SIGALRM\n"); 685 // fprintf(stderr, "alarm_handler(): Received SIGALRM\n");
681 686
682 // jump 687 // jump
683 siglongjmp(jmp_buffer, 1); 688 siglongjmp(jmp_buffer, 1);
684} 689}
685 690
686 691
687const char* Modem::authFile(Auth method, int version) { 692const char* Modem::authFile(Auth method, int version) {
688 switch(method|version) { 693 switch(method|version) {
689 case PAP|Original: 694 case PAP|Original:
690 return PAP_AUTH_FILE; 695 return PAP_AUTH_FILE;
691 break; 696 break;
692 case PAP|New: 697 case PAP|New:
693 return PAP_AUTH_FILE".new"; 698 return PAP_AUTH_FILE".new";
694 break; 699 break;
695 case PAP|Old: 700 case PAP|Old:
696 return PAP_AUTH_FILE".old"; 701 return PAP_AUTH_FILE".old";
697 break; 702 break;
698 case CHAP|Original: 703 case CHAP|Original:
699 return CHAP_AUTH_FILE; 704 return CHAP_AUTH_FILE;
700 break; 705 break;
701 case CHAP|New: 706 case CHAP|New:
702 return CHAP_AUTH_FILE".new"; 707 return CHAP_AUTH_FILE".new";
703 break; 708 break;
704 case CHAP|Old: 709 case CHAP|Old:
705 return CHAP_AUTH_FILE".old"; 710 return CHAP_AUTH_FILE".old";
706 break; 711 break;
707 default: 712 default:
708 return 0L; 713 return 0L;
709 } 714 }
710} 715}
711 716
712 717
713bool Modem::createAuthFile(Auth method, const char *username, const char *password) { 718bool Modem::createAuthFile(Auth method, const char *username, const char *password) {
714 const char *authfile, *oldName, *newName; 719 const char *authfile, *oldName, *newName;
715 char line[100]; 720 char line[100];
716 char regexp[2*MaxStrLen+30]; 721 char regexp[2*MaxStrLen+30];
717 regex_t preg; 722 regex_t preg;
718 723
719 if(!(authfile = authFile(method))) 724 if(!(authfile = authFile(method)))
720 return false; 725 return false;
721 726
722 if(!(newName = authFile(method, New))) 727 if(!(newName = authFile(method, New)))
723 return false; 728 return false;
724 729
725 // look for username, "username" or 'username' 730 // look for username, "username" or 'username'
726 // if you modify this RE you have to adapt regexp's size above 731 // if you modify this RE you have to adapt regexp's size above
727 snprintf(regexp, sizeof(regexp), "^[ \t]*%s[ \t]\\|^[ \t]*[\"\']%s[\"\']", 732 snprintf(regexp, sizeof(regexp), "^[ \t]*%s[ \t]\\|^[ \t]*[\"\']%s[\"\']",
728 username,username); 733 username,username);
729 MY_ASSERT(regcomp(&preg, regexp, 0) == 0); 734 MY_ASSERT(regcomp(&preg, regexp, 0) == 0);
730 735
731 // copy to new file pap- or chap-secrets 736 // copy to new file pap- or chap-secrets
732 int old_umask = umask(0077); 737 int old_umask = umask(0077);
733 FILE *fout = fopen(newName, "w"); 738 FILE *fout = fopen(newName, "w");
734 if(fout) { 739 if(fout) {
735 // copy old file 740 // copy old file
736 FILE *fin = fopen(authfile, "r"); 741 FILE *fin = fopen(authfile, "r");
737 if(fin) { 742 if(fin) {
738 while(fgets(line, sizeof(line), fin)) { 743 while(fgets(line, sizeof(line), fin)) {
739 if(regexec(&preg, line, 0, 0L, 0) == 0) 744 if(regexec(&preg, line, 0, 0L, 0) == 0)
740 continue; 745 continue;
741 fputs(line, fout); 746 fputs(line, fout);
742 } 747 }
743 fclose(fin); 748 fclose(fin);
744 } 749 }
745 750
746 // append user/pass pair 751 // append user/pass pair
747 fprintf(fout, "\"%s\"\t*\t\"%s\"\n", username, password); 752 fprintf(fout, "\"%s\"\t*\t\"%s\"\n", username, password);
748 fclose(fout); 753 fclose(fout);
749 } 754 }
750 755
751 // restore umask 756 // restore umask
752 umask(old_umask); 757 umask(old_umask);
753 758
754 // free memory allocated by regcomp 759 // free memory allocated by regcomp
755 regfree(&preg); 760 regfree(&preg);
756 761
757 if(!(oldName = authFile(method, Old))) 762 if(!(oldName = authFile(method, Old)))
758 return false; 763 return false;
759 764
760 // delete old file if any 765 // delete old file if any
761 unlink(oldName); 766 unlink(oldName);
762 767
763 rename(authfile, oldName); 768 rename(authfile, oldName);
764 rename(newName, authfile); 769 rename(newName, authfile);
765 770
766 return true; 771 return true;
767} 772}
768 773
769 774
770bool Modem::removeAuthFile(Auth method) { 775bool Modem::removeAuthFile(Auth method) {
771 const char *authfile, *oldName; 776 const char *authfile, *oldName;
772 777
773 if(!(authfile = authFile(method))) 778 if(!(authfile = authFile(method)))
774 return false; 779 return false;
775 if(!(oldName = authFile(method, Old))) 780 if(!(oldName = authFile(method, Old)))
776 return false; 781 return false;
777 782
778 if(access(oldName, F_OK) == 0) { 783 if(access(oldName, F_OK) == 0) {
779 unlink(authfile); 784 unlink(authfile);
780 return (rename(oldName, authfile) == 0); 785 return (rename(oldName, authfile) == 0);
781 } else 786 } else
782 return false; 787 return false;
783} 788}
784 789
785 790
786bool Modem::setSecret(int method, const char* name, const char* password) 791bool Modem::setSecret(int method, const char* name, const char* password)
787{ 792{
788 793
789 Auth auth; 794 Auth auth;
790 if(method == AUTH_PAPCHAP) 795 if(method == AUTH_PAPCHAP)
791 return setSecret(AUTH_PAP, name, password) && 796 return setSecret(AUTH_PAP, name, password) &&
792 setSecret(AUTH_CHAP, name, password); 797 setSecret(AUTH_CHAP, name, password);
793 798
794 switch(method) { 799 switch(method) {
795 case AUTH_PAP: 800 case AUTH_PAP:
796 auth = Modem::PAP; 801 auth = Modem::PAP;
797 break; 802 break;
798 case AUTH_CHAP: 803 case AUTH_CHAP:
799 auth = Modem::CHAP; 804 auth = Modem::CHAP;
800 break; 805 break;
801 default: 806 default:
802 return false; 807 return false;
803 } 808 }
804 809
805 return createAuthFile(auth, name, password); 810 return createAuthFile(auth, name, password);
806 811
807} 812}
808 813
809bool Modem::removeSecret(int method) 814bool Modem::removeSecret(int method)
810{ 815{
811 Auth auth; 816 Auth auth;
812 817
813 switch(method) { 818 switch(method) {
814 case AUTH_PAP: 819 case AUTH_PAP:
815 auth = Modem::PAP; 820 auth = Modem::PAP;
816 break; 821 break;
817 case AUTH_CHAP: 822 case AUTH_CHAP:
818 auth = Modem::CHAP; 823 auth = Modem::CHAP;
819 break; 824 break;
820 default: 825 default:
821 return false; 826 return false;
822 } 827 }
823 return removeAuthFile( auth ); 828 return removeAuthFile( auth );
824} 829}
825 830
826int checkForInterface() 831int checkForInterface()
827{ 832{
828// I don't know if Linux needs more initialization to get the ioctl to 833// I don't know if Linux needs more initialization to get the ioctl to
829// work, pppd seems to hint it does. But BSD doesn't, and the following 834// work, pppd seems to hint it does. But BSD doesn't, and the following
830// code should compile. 835// code should compile.
831#if (defined(HAVE_NET_IF_PPP_H) || defined(HAVE_LINUX_IF_PPP_H)) && !defined(__svr4__) 836#if (defined(HAVE_NET_IF_PPP_H) || defined(HAVE_LINUX_IF_PPP_H)) && !defined(__svr4__)
832 int s, ok; 837 int s, ok;
833 struct ifreq ifr; 838 struct ifreq ifr;
834 // extern char *no_ppp_msg; 839 // extern char *no_ppp_msg;
835 840
836 if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) 841 if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
837 return 1; /* can't tell */ 842 return 1; /* can't tell */
838 843
839 strlcpy(ifr.ifr_name, "ppp0", sizeof (ifr.ifr_name)); 844 strlcpy(ifr.ifr_name, "ppp0", sizeof (ifr.ifr_name));
840 ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) >= 0; 845 ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) >= 0;
841 close(s); 846 close(s);
842 847
843 if (ok == -1) { 848 if (ok == -1) {
844// This is ifdef'd FreeBSD, because FreeBSD is the only BSD that supports 849// This is ifdef'd FreeBSD, because FreeBSD is the only BSD that supports
845// KLDs, the old LKM interface couldn't handle loading devices 850// KLDs, the old LKM interface couldn't handle loading devices
846// dynamically, and thus can't load ppp support on the fly 851// dynamically, and thus can't load ppp support on the fly
847#ifdef __FreeBSD__ 852#ifdef __FreeBSD__
848 // If we failed to load ppp support and don't have it already. 853 // If we failed to load ppp support and don't have it already.
849 if (kldload("if_ppp") == -1) { 854 if (kldload("if_ppp") == -1) {
850 return -1; 855 return -1;
851 } 856 }
852 return 0; 857 return 0;
853#else 858#else
854 return -1; 859 return -1;
855#endif 860#endif
856 } 861 }
857 return 0; 862 return 0;
858#else 863#else
859// We attempt to use the SunOS/SysVr4 method and stat /dev/ppp 864// We attempt to use the SunOS/SysVr4 method and stat /dev/ppp
860 struct stat buf; 865 struct stat buf;
861 866
862 memset(&buf, 0, sizeof(buf)); 867 memset(&buf, 0, sizeof(buf));
863 return stat("/dev/ppp", &buf); 868 return stat("/dev/ppp", &buf);
864#endif 869#endif
865} 870}
866 871
867bool Modem::execpppd(const char *arguments) { 872bool Modem::execpppd(const char *arguments) {
868 char buf[MAX_CMDLEN]; 873 char buf[MAX_CMDLEN];
869 char *args[MaxArgs]; 874 char *args[MaxArgs];
870 pid_t pgrpid; 875 pid_t pgrpid;
871 876
872 if(modemfd<0) 877 if(modemfd<0)
873 return false; 878 return false;
874 879
875 _pppdExitStatus = -1; 880 _pppdExitStatus = -1;
876 881
877 (void)::pipe( m_pppdLOG ); 882 (void)::pipe( m_pppdLOG );
878 883
879 switch(pppdPid = fork()) 884 switch(pppdPid = fork())
880 { 885 {
881 case -1: 886 case -1:
882 fprintf(stderr,"In parent: fork() failed\n"); 887 fprintf(stderr,"In parent: fork() failed\n");
883 ::close( m_pppdLOG[0] ); 888 ::close( m_pppdLOG[0] );
884 ::close( m_pppdLOG[1] ); 889 ::close( m_pppdLOG[1] );
885 return false; 890 return false;
886 break; 891 break;
887 892
888 case 0: 893 case 0:
889 // let's parse the arguments the user supplied into UNIX suitable form 894 // let's parse the arguments the user supplied into UNIX suitable form
890 // that is a list of pointers each pointing to exactly one word 895 // that is a list of pointers each pointing to exactly one word
891 strlcpy(buf, arguments); 896 strlcpy(buf, arguments);
892 parseargs(buf, args); 897 parseargs(buf, args);
893 // become a session leader and let /dev/ttySx 898 // become a session leader and let /dev/ttySx
894 // be the controlling terminal. 899 // be the controlling terminal.
895 pgrpid = setsid(); 900 pgrpid = setsid();
896#ifdef TIOCSCTTY 901#ifdef TIOCSCTTY
897 if(ioctl(modemfd, TIOCSCTTY, 0)<0) 902 if(ioctl(modemfd, TIOCSCTTY, 0)<0)
898 fprintf(stderr, "ioctl() failed.\n"); 903 fprintf(stderr, "ioctl() failed.\n");
899#elif defined (TIOCSPGRP) 904#elif defined (TIOCSPGRP)
900 if(ioctl(modemfd, TIOCSPGRP, &pgrpid)<0) 905 if(ioctl(modemfd, TIOCSPGRP, &pgrpid)<0)
901 fprintf(stderr, "ioctl() failed.\n"); 906 fprintf(stderr, "ioctl() failed.\n");
902#endif 907#endif
903 if(tcsetpgrp(modemfd, pgrpid)<0) 908 if(tcsetpgrp(modemfd, pgrpid)<0)
904 fprintf(stderr, "tcsetpgrp() failed.\n"); 909 fprintf(stderr, "tcsetpgrp() failed.\n");
905 910
906 ::close( m_pppdLOG[0] ); 911 ::close( m_pppdLOG[0] );
907 ::setenv( "LANG", "C", 1 ); // overwrite 912 ::setenv( "LANG", "C", 1 ); // overwrite
908 dup2(m_pppdLOG[1], 11 ); // for logfd 11 913 dup2(m_pppdLOG[1], 11 ); // for logfd 11
909 dup2(modemfd, 0); 914 dup2(modemfd, 0);
910 dup2(modemfd, 1); 915 dup2(modemfd, 1);
911 916
912 917
913 switch (checkForInterface()) { 918 switch (checkForInterface()) {
914 case 1: 919 case 1:
915 fprintf(stderr, "Cannot determine if kernel supports ppp.\n"); 920 fprintf(stderr, "Cannot determine if kernel supports ppp.\n");
916 break; 921 break;
917 case -1: 922 case -1:
918 fprintf(stderr, "Kernel does not support ppp, oops.\n"); 923 fprintf(stderr, "Kernel does not support ppp, oops.\n");
919 break; 924 break;
920 case 0: 925 case 0:
921 fprintf(stderr, "Kernel supports ppp alright.\n"); 926 fprintf(stderr, "Kernel supports ppp alright.\n");
922 break; 927 break;
923 } 928 }
924 929
925 execve(pppdPath(), args, 0L); 930 execve(pppdPath(), args, 0L);
926 _exit(0); 931 _exit(0);
927 break; 932 break;
928 933
929 default: 934 default:
930 odebug << "In parent: pppd pid " << pppdPid << "\n" << oendl; 935 odebug << "In parent: pppd pid " << pppdPid << "\n" << oendl;
931 close(modemfd); 936 close(modemfd);
932 937
933 ::close( m_pppdLOG[1] ); 938 ::close( m_pppdLOG[1] );
934 // set it to nonblocking io 939 // set it to nonblocking io
935 int flag = ::fcntl( m_pppdLOG[0], F_GETFL ); 940 int flag = ::fcntl( m_pppdLOG[0], F_GETFL );
936 941
937 if ( !(flag & O_NONBLOCK) ) { 942 if ( !(flag & O_NONBLOCK) ) {
938 odebug << "Setting nonblocking io" << oendl; 943 odebug << "Setting nonblocking io" << oendl;
939 flag |= O_NONBLOCK; 944 flag |= O_NONBLOCK;
940 ::fcntl(m_pppdLOG[0], F_SETFL, flag ); 945 ::fcntl(m_pppdLOG[0], F_SETFL, flag );
941 } 946 }
942 947
943 delete m_modemDebug; 948 delete m_modemDebug;
944 m_modemDebug = new QSocketNotifier(m_pppdLOG[0], QSocketNotifier::Read, this ); 949 m_modemDebug = new QSocketNotifier(m_pppdLOG[0], QSocketNotifier::Read, this );
945 connect(m_modemDebug, SIGNAL(activated(int) ), 950 connect(m_modemDebug, SIGNAL(activated(int) ),
946 this, SLOT(slotModemDebug(int) ) ); 951 this, SLOT(slotModemDebug(int) ) );
947 952
948 modemfd = -1; 953 modemfd = -1;
949 m_pppdDev = QString::fromLatin1("ppp0"); 954 m_pppdDev = QString::fromLatin1("ppp0");
950 return true; 955 return true;
951 break; 956 break;
952 } 957 }
953} 958}
954 959
955 960
956bool Modem::killpppd() { 961bool Modem::killpppd() {
957 odebug << "In killpppd and pid is " << pppdPid << "" << oendl; 962 odebug << "In killpppd and pid is " << pppdPid << "" << oendl;
958 if(pppdPid > 0) { 963 if(pppdPid > 0) {
959 delete m_modemDebug; 964 delete m_modemDebug;
960 m_modemDebug = 0; 965 m_modemDebug = 0;
961 odebug << "In killpppd(): Sending SIGTERM to " << pppdPid << "\n" << oendl; 966 odebug << "In killpppd(): Sending SIGTERM to " << pppdPid << "\n" << oendl;
962 if(kill(pppdPid, SIGTERM) < 0) { 967 if(kill(pppdPid, SIGTERM) < 0) {
963 odebug << "Error terminating " << pppdPid << ". Sending SIGKILL\n" << oendl; 968 odebug << "Error terminating " << pppdPid << ". Sending SIGKILL\n" << oendl;
964 if(kill(pppdPid, SIGKILL) < 0) { 969 if(kill(pppdPid, SIGKILL) < 0) {
965 odebug << "Error killing " << pppdPid << "\n" << oendl; 970 odebug << "Error killing " << pppdPid << "\n" << oendl;
966 return false; 971 return false;
967 } 972 }
968 } 973 }
969 } 974 }
970 return true; 975 return true;
971} 976}
972 977
973 978
974void Modem::parseargs(char* buf, char** args) { 979void Modem::parseargs(char* buf, char** args) {
975 int nargs = 0; 980 int nargs = 0;
976 int quotes; 981 int quotes;
977 982
978 while(nargs < MaxArgs-1 && *buf != '\0') { 983 while(nargs < MaxArgs-1 && *buf != '\0') {
979 984
980 quotes = 0; 985 quotes = 0;
981 986
982 // Strip whitespace. Use nulls, so that the previous argument is 987 // Strip whitespace. Use nulls, so that the previous argument is
983 // terminated automatically. 988 // terminated automatically.
984 989
985 while ((*buf == ' ' ) || (*buf == '\t' ) || (*buf == '\n' ) ) 990 while ((*buf == ' ' ) || (*buf == '\t' ) || (*buf == '\n' ) )
986 *buf++ = '\0'; 991 *buf++ = '\0';
987 992
988 // detect begin of quoted argument 993 // detect begin of quoted argument
989 if (*buf == '"' || *buf == '\'') { 994 if (*buf == '"' || *buf == '\'') {
990 quotes = *buf; 995 quotes = *buf;
991 *buf++ = '\0'; 996 *buf++ = '\0';
992 } 997 }
993 998
994 // save the argument 999 // save the argument
995 if(*buf != '\0') { 1000 if(*buf != '\0') {
996 *args++ = buf; 1001 *args++ = buf;
997 nargs++; 1002 nargs++;
998 } 1003 }
999 1004
1000 if (!quotes) 1005 if (!quotes)
1001 while ((*buf != '\0') && (*buf != '\n') && 1006 while ((*buf != '\0') && (*buf != '\n') &&
1002 (*buf != '\t') && (*buf != ' ')) 1007 (*buf != '\t') && (*buf != ' '))
1003 buf++; 1008 buf++;
1004 else { 1009 else {
1005 while ((*buf != '\0') && (*buf != quotes)) 1010 while ((*buf != '\0') && (*buf != quotes))
1006 buf++; 1011 buf++;
1007 *buf++ = '\0'; 1012 *buf++ = '\0';
1008 } 1013 }
1009 } 1014 }
1010 1015
1011 *args = 0L; 1016 *args = 0L;
1012} 1017}
1013 1018
1014bool Modem::execPPPDaemon(const QString & arguments) 1019bool Modem::execPPPDaemon(const QString & arguments)
1015{ 1020{
1016 if(execpppd(arguments)) { 1021 if(execpppd(arguments)) {
1017 _pppdata->setpppdRunning(true); 1022 _pppdata->setpppdRunning(true);
1018 return true; 1023 return true;
1019 } else 1024 } else
1020 return false; 1025 return false;
1021} 1026}
1022 1027
1023void Modem::killPPPDaemon() 1028void Modem::killPPPDaemon()
1024{ 1029{
1025 _pppdata->setpppdRunning(false); 1030 _pppdata->setpppdRunning(false);
1026 killpppd(); 1031 killpppd();
1027} 1032}
1028 1033
1029int Modem::pppdExitStatus() 1034int Modem::pppdExitStatus()
1030{ 1035{
1031 return _pppdExitStatus; 1036 return _pppdExitStatus;
1032} 1037}
1033 1038
1034int Modem::openResolv(int flags) 1039int Modem::openResolv(int flags)
1035{ 1040{
1036 int fd; 1041 int fd;
1037 if ((fd = open(_PATH_RESCONF, flags)) == -1) { 1042 if ((fd = open(_PATH_RESCONF, flags)) == -1) {
1038 odebug << "error opening resolv.conf!" << oendl; 1043 odebug << "error opening resolv.conf!" << oendl;
1039 fd = open(DEVNULL, O_RDONLY); 1044 fd = open(DEVNULL, O_RDONLY);
1040 } 1045 }
1041 return fd; 1046 return fd;
1042} 1047}
1043 1048
1044bool Modem::setHostname(const QString & name) 1049bool Modem::setHostname(const QString & name)
1045{ 1050{
1046 return sethostname(name, name.length()) == 0; 1051 return sethostname(name, name.length()) == 0;
1047} 1052}
1048 1053
1049QString Modem::pppDevice()const { 1054QString Modem::pppDevice()const {
1050 return m_pppdDev; 1055 return m_pppdDev;
1051} 1056}
1052void Modem::setPPPDevice( const QString& dev ) { 1057void Modem::setPPPDevice( const QString& dev ) {
1053 m_pppdDev = dev; 1058 m_pppdDev = dev;
1054} 1059}
1055pid_t Modem::pppPID()const { 1060pid_t Modem::pppPID()const {
1056 return pppdPid; 1061 return pppdPid;
1057} 1062}
1058void Modem::setPPPDPid( pid_t pid ) { 1063void Modem::setPPPDPid( pid_t pid ) {
1059 odebug << "Modem setting pid" << oendl; 1064 odebug << "Modem setting pid" << oendl;
1060 _pppdExitStatus = -1; 1065 _pppdExitStatus = -1;
1061 pppdPid = pid; 1066 pppdPid = pid;
1062 modemfd = -1; 1067 modemfd = -1;
1063} 1068}
1064void Modem::slotModemDebug(int fd) { 1069void Modem::slotModemDebug(int fd) {
1065 char buf[2049]; 1070 char buf[2049];
1066 int len; 1071 int len;
1067 1072
1068 // read in pppd data look for Using interface 1073 // read in pppd data look for Using interface
1069 // then read the interface 1074 // then read the interface
1070 // we limit to 10 device now 0-9 1075 // we limit to 10 device now 0-9
1071 if((len = ::read(fd, buf, 2048)) > 0) { 1076 if((len = ::read(fd, buf, 2048)) > 0) {
1072 buf[len+1] = '\0'; 1077 buf[len+1] = '\0';
1073 char *found; 1078 char *found;
1074 if ( (found = ::strstr(buf, "Using interface ") ) ) { 1079 if ( (found = ::strstr(buf, "Using interface ") ) ) {
1075 found += 16; 1080 found += 16;
1076 m_pppdDev = QString::fromLatin1(found, 5 ); 1081 m_pppdDev = QString::fromLatin1(found, 5 );
1077 m_pppdDev = m_pppdDev.simplifyWhiteSpace(); 1082 m_pppdDev = m_pppdDev.simplifyWhiteSpace();
1078 } 1083 }
1079 } 1084 }
1080} 1085}
diff --git a/noncore/settings/networksettings/ppp/ppp.pro b/noncore/settings/networksettings/ppp/ppp.pro
index 62ca2b5..45fa0ee 100644
--- a/noncore/settings/networksettings/ppp/ppp.pro
+++ b/noncore/settings/networksettings/ppp/ppp.pro
@@ -1,17 +1,14 @@
1#TEMPLATE = app
2#
3TEMPLATE = lib 1TEMPLATE = lib
4#CONFIG += qt plugin warn_on
5 CONFIG += qt plugin warn_on 2 CONFIG += qt plugin warn_on
6DESTDIR = $(OPIEDIR)/plugins/networksettings 3DESTDIR = $(OPIEDIR)/plugins/networksettings
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 4 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 chooserwidget.cpp devices.cpp 5 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/ 6 INCLUDEPATH+= $(OPIEDIR)/include ../ ../interfaces/
10 DEPENDPATH+= $(OPIEDIR)/include 7 DEPENDPATH+= $(OPIEDIR)/include
11LIBS += -lqpe -L../interfaces/ -linterfaces 8LIBS += -lqpe -L../interfaces/ -linterfaces
12 TARGET = kppp 9 TARGET = kppp
13 VERSION = 1.0.0 10 VERSION = 1.0.0
14 11
15 12
16 13
17include ( $(OPIEDIR)/include.pro ) 14include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/settings/networksettings/ppp/pppconfig.cpp b/noncore/settings/networksettings/ppp/pppconfig.cpp
index a8c99fd..d2a1490 100644
--- a/noncore/settings/networksettings/ppp/pppconfig.cpp
+++ b/noncore/settings/networksettings/ppp/pppconfig.cpp
@@ -1,75 +1,79 @@
1
2#include <qlayout.h>
3#include <qmessagebox.h>
4#include <qtabwidget.h>
5
6#include "accounts.h" 1#include "accounts.h"
7#include "devices.h" 2#include "devices.h"
8#include "general.h" 3#include "general.h"
9#include "interfaceppp.h" 4#include "interfaceppp.h"
10#include "modem.h" 5#include "modem.h"
11#include "pppconfig.h" 6#include "pppconfig.h"
12#include "pppdata.h" 7#include "pppdata.h"
13#include "runtests.h" 8#include "runtests.h"
14 9
10/* OPIE */
11#include <opie2/odebug.h>
12using namespace Opie::Core;
13
14/* QT */
15#include <qlayout.h>
16#include <qmessagebox.h>
17#include <qtabwidget.h>
18
15PPPConfigWidget::PPPConfigWidget( InterfacePPP* iface, QWidget *parent, 19PPPConfigWidget::PPPConfigWidget( InterfacePPP* iface, QWidget *parent,
16 const char *name, 20 const char *name,
17 bool modal, WFlags fl ) 21 bool modal, WFlags fl )
18 : QDialog(parent, name, modal, fl) 22 : QDialog(parent, name, modal, fl)
19{ 23{
20 setCaption(tr("Configure Modem")); 24 setCaption(tr("Configure Modem"));
21 int result = runTests(); 25 int result = runTests();
22 if(result == TEST_CRITICAL){ 26 if(result == TEST_CRITICAL){
23 QMessageBox::critical(0, tr("Modem failure"), tr("A critical failure appeard while testing the modem") ); 27 QMessageBox::critical(0, tr("Modem failure"), tr("A critical failure appeard while testing the modem") );
24 return; 28 return;
25 } 29 }
26 30
27 interface = iface; 31 interface = iface;
28 odebug << "PPPConfigWidget::PPPConfigWidget" << oendl; 32 odebug << "PPPConfigWidget::PPPConfigWidget" << oendl;
29 odebug << " interface->getHardwareName >" << interface->getHardwareName().latin1() << "<" << oendl; 33 odebug << " interface->getHardwareName >" << interface->getHardwareName().latin1() << "<" << oendl;
30 34
31 odebug << " _pppdata->accname >" << interface->data()->accname().latin1() << "<" << oendl; 35 odebug << " _pppdata->accname >" << interface->data()->accname().latin1() << "<" << oendl;
32 36
33 37
34 QVBoxLayout *layout = new QVBoxLayout( this ); 38 QVBoxLayout *layout = new QVBoxLayout( this );
35 layout->setSpacing( 0 ); 39 layout->setSpacing( 0 );
36 layout->setMargin( 1 ); 40 layout->setMargin( 1 );
37 tabWindow = new QTabWidget( this, "tabWidget" ); 41 tabWindow = new QTabWidget( this, "tabWidget" );
38 layout->addWidget( tabWindow ); 42 layout->addWidget( tabWindow );
39 43
40 accounts = new AccountWidget( interface->data(), tabWindow, "accounts", Qt::WStyle_ContextHelp ); 44 accounts = new AccountWidget( interface->data(), tabWindow, "accounts", Qt::WStyle_ContextHelp );
41 tabWindow->addTab( accounts, tr("&Accounts") ); 45 tabWindow->addTab( accounts, tr("&Accounts") );
42 devices = new DevicesWidget( interface, tabWindow, "devices", Qt::WStyle_ContextHelp ); 46 devices = new DevicesWidget( interface, tabWindow, "devices", Qt::WStyle_ContextHelp );
43 tabWindow->addTab( devices, tr("&Devices") ); 47 tabWindow->addTab( devices, tr("&Devices") );
44 48
45//OLD: 49//OLD:
46// modem1 = new ModemWidget( interface, tabWindow, "modem1" ); 50// modem1 = new ModemWidget( interface, tabWindow, "modem1" );
47// tabWindow->addTab( modem1, tr("&Device") ); 51// tabWindow->addTab( modem1, tr("&Device") );
48// modem2 = new ModemWidget2( interface, tabWindow, "modem2" ); 52// modem2 = new ModemWidget2( interface, tabWindow, "modem2" );
49// tabWindow->addTab( modem2, tr("&Modem") ); 53// tabWindow->addTab( modem2, tr("&Modem") );
50 54
51} 55}
52 56
53 57
54PPPConfigWidget::~PPPConfigWidget() 58PPPConfigWidget::~PPPConfigWidget()
55{ 59{
56 60
57} 61}
58 62
59void PPPConfigWidget::accept() 63void PPPConfigWidget::accept()
60{ 64{
61 odebug << "PPPConfigWidget::accept" << oendl; 65 odebug << "PPPConfigWidget::accept" << oendl;
62 odebug << " _pppdata->accname >" << interface->data()->accname().latin1() << "<" << oendl; 66 odebug << " _pppdata->accname >" << interface->data()->accname().latin1() << "<" << oendl;
63 odebug << " interface->getHardwareName >" << interface->getHardwareName().latin1() << "<" << oendl; 67 odebug << " interface->getHardwareName >" << interface->getHardwareName().latin1() << "<" << oendl;
64 interface->setInterfaceName( interface->data()->devname() ); 68 interface->setInterfaceName( interface->data()->devname() );
65 interface->setHardwareName( interface->data()->accname() ); 69 interface->setHardwareName( interface->data()->accname() );
66 interface->save(); 70 interface->save();
67 QDialog::accept(); 71 QDialog::accept();
68} 72}
69 73
70 74
71void PPPConfigWidget::reject() 75void PPPConfigWidget::reject()
72{ 76{
73 interface->data()->cancel(); 77 interface->data()->cancel();
74 QDialog::reject(); 78 QDialog::reject();
75} 79}
diff --git a/noncore/settings/networksettings/ppp/pppdata.cpp b/noncore/settings/networksettings/ppp/pppdata.cpp
index 567ccf8..eb03ef4 100644
--- a/noncore/settings/networksettings/ppp/pppdata.cpp
+++ b/noncore/settings/networksettings/ppp/pppdata.cpp
@@ -1,1495 +1,1497 @@
1/* 1/*
2 * kPPP: A pppd front end for the KDE project 2 * kPPP: A pppd front end for the KDE project
3 * 3 *
4 * $Id$ 4 * $Id$
5 * 5 *
6 * Copyright (C) 1997 Bernd Johannes Wuebben 6 * Copyright (C) 1997 Bernd Johannes Wuebben
7 * wuebben@math.cornell.edu 7 * wuebben@math.cornell.edu
8 * 8 *
9 * based on EzPPP: 9 * based on EzPPP:
10 * Copyright (C) 1997 Jay Painter 10 * Copyright (C) 1997 Jay Painter
11 * 11 *
12 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Library General Public 13 * modify it under the terms of the GNU Library General Public
14 * License as published by the Free Software Foundation; either 14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version. 15 * version 2 of the License, or (at your option) any later version.
16 * 16 *
17 * This program is distributed in the hope that it will be useful, 17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details. 20 * Library General Public License for more details.
21 * 21 *
22 * You should have received a copy of the GNU Library General Public 22 * You should have received a copy of the GNU Library General Public
23 * License along with this program; if not, write to the Free 23 * License along with this program; if not, write to the Free
24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */ 25 */
26 26
27#include "pppdata.h" 27#include "pppdata.h"
28#include "runtests.h" 28#include "runtests.h"
29//#include "devices.h" 29
30//#include <klocale.h> 30/* OPIE */
31#include <opie2/odebug.h>
31#include <qpe/config.h> 32#include <qpe/config.h>
33using namespace Opie::Core;
34
35/* QT */
32#include <qmessagebox.h> 36#include <qmessagebox.h>
33#include <qapplication.h> 37#include <qapplication.h>
34// #include <klocale.h> 38
35// #include <kconfig.h> 39/* STD */
36// #include <kmessagebox.h>
37// #include <kapplication.h>
38#include <assert.h> 40#include <assert.h>
39 41
40#define SEPARATOR -sseepp- 42#define SEPARATOR -sseepp-
41#define SEP QString("%1SEPARATOR%1") 43#define SEP QString("%1SEPARATOR%1")
42 44
43PPPData::PPPData() 45PPPData::PPPData()
44 : passwd(""), 46 : passwd(""),
45 _modemName(""), 47 _modemName(""),
46 highcount(-1), // start out with no entries 48 highcount(-1), // start out with no entries
47 highcountdev(-1), // start out with no entries 49 highcountdev(-1), // start out with no entries
48// caccount(-1), // set the current account index also 50// caccount(-1), // set the current account index also
49 suidprocessid(-1), // process ID of setuid child 51 suidprocessid(-1), // process ID of setuid child
50 pppdisrunning(false), 52 pppdisrunning(false),
51 pppderror(0) 53 pppderror(0)
52{ 54{
53 highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1; 55 highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1;
54 highcountdev = readNumConfig(GENERAL_GRP, NUMDEVICES_KEY, 0) - 1; 56 highcountdev = readNumConfig(GENERAL_GRP, NUMDEVICES_KEY, 0) - 1;
55 Config cfg = config(); 57 Config cfg = config();
56 cfg.setGroup(GENERAL_GRP); 58 cfg.setGroup(GENERAL_GRP);
57 accountList = cfg.readListEntry(ACCOUNT_LIST, ',' ); 59 accountList = cfg.readListEntry(ACCOUNT_LIST, ',' );
58 deviceList = cfg.readListEntry(DEVICESNAMES_LIST, ',' ); 60 deviceList = cfg.readListEntry(DEVICESNAMES_LIST, ',' );
59 odebug << "PPPData::PPPData has a accountList " << accountList.join("---").latin1() << "" << oendl; 61 odebug << "PPPData::PPPData has a accountList " << accountList.join("---").latin1() << "" << oendl;
60 odebug << "PPPData::PPPData has a deviceList " << deviceList.join("---").latin1() << "" << oendl; 62 odebug << "PPPData::PPPData has a deviceList " << deviceList.join("---").latin1() << "" << oendl;
61 63
62// if (highcount > MAX_ACCOUNTS) 64// if (highcount > MAX_ACCOUNTS)
63// highcount = MAX_ACCOUNTS; 65// highcount = MAX_ACCOUNTS;
64 66
65 // if(highcount >= 0 && defaultAccount().isEmpty()) { 67 // if(highcount >= 0 && defaultAccount().isEmpty()) {
66// setAccountbyIndex(0); 68// setAccountbyIndex(0);
67// setDefaultAccount(accname()); 69// setDefaultAccount(accname());
68// } else if(!setAccount(defaultAccount())) 70// } else if(!setAccount(defaultAccount()))
69 setDefaultAccount(accname()); 71 setDefaultAccount(accname());
70 72
71 // start out with internal debugging disabled 73 // start out with internal debugging disabled
72 // the user is still free to specify `debug' on his own 74 // the user is still free to specify `debug' on his own
73 setPPPDebug(false); 75 setPPPDebug(false);
74 76
75 ::pppdVersion(&pppdVer, &pppdMod, &pppdPatch); 77 ::pppdVersion(&pppdVer, &pppdMod, &pppdPatch);
76 78
77} 79}
78 80
79Config PPPData::config() 81Config PPPData::config()
80{ 82{
81 return Config("NetworkSetupPPP"); 83 return Config("NetworkSetupPPP");
82} 84}
83 85
84// 86//
85// save configuration 87// save configuration
86// 88//
87void PPPData::save() 89void PPPData::save()
88{ 90{
89 odebug << "PPPData saving data" << oendl; 91 odebug << "PPPData saving data" << oendl;
90 writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count()); 92 writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count());
91 writeConfig(GENERAL_GRP, NUMDEVICES_KEY, highcountdev + 1); 93 writeConfig(GENERAL_GRP, NUMDEVICES_KEY, highcountdev + 1);
92 QString key; 94 QString key;
93 QStringList keys; 95 QStringList keys;
94 Config cfg = config(); 96 Config cfg = config();
95 cfg.setGroup(GENERAL_GRP); 97 cfg.setGroup(GENERAL_GRP);
96 cfg.writeEntry(ACCOUNT_LIST, accountList, ',' ); 98 cfg.writeEntry(ACCOUNT_LIST, accountList, ',' );
97 cfg.writeEntry(DEVICESNAMES_LIST, deviceList, ',' ); 99 cfg.writeEntry(DEVICESNAMES_LIST, deviceList, ',' );
98 100
99 for( QMap<QString,QString>::Iterator it = stringEntries.begin(); 101 for( QMap<QString,QString>::Iterator it = stringEntries.begin();
100 it != stringEntries.end(); ++it ){ 102 it != stringEntries.end(); ++it ){
101 QString val = it.data(); 103 QString val = it.data();
102 key = it.key(); 104 key = it.key();
103// odebug << "saving " << key.latin1() << " -> " << val.latin1() << "" << oendl; 105// odebug << "saving " << key.latin1() << " -> " << val.latin1() << "" << oendl;
104 keys = QStringList::split( "SEPARATOR", key ); 106 keys = QStringList::split( "SEPARATOR", key );
105 //odebug << "group >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.latin1() << "<" << oendl; 107 //odebug << "group >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.latin1() << "<" << oendl;
106 cfg.setGroup(keys[0]); 108 cfg.setGroup(keys[0]);
107 cfg.writeEntry(keys[1], val); 109 cfg.writeEntry(keys[1], val);
108 } 110 }
109 for( QMap<QString,int>::Iterator it = intEntries.begin(); 111 for( QMap<QString,int>::Iterator it = intEntries.begin();
110 it != intEntries.end(); ++it ){ 112 it != intEntries.end(); ++it ){
111 int val = it.data(); 113 int val = it.data();
112 key = it.key(); 114 key = it.key();
113// odebug << "saving " << key.latin1() << " -> " << val << "" << oendl; 115// odebug << "saving " << key.latin1() << " -> " << val << "" << oendl;
114 keys = QStringList::split( "SEPARATOR", key ); 116 keys = QStringList::split( "SEPARATOR", key );
115 //odebug << "group >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< val " << val << "" << oendl; 117 //odebug << "group >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< val " << val << "" << oendl;
116 cfg.setGroup(keys[0]); 118 cfg.setGroup(keys[0]);
117 cfg.writeEntry(keys[1], val); 119 cfg.writeEntry(keys[1], val);
118 } 120 }
119 for( QMap<QString,QStringList>::Iterator it = listEntries.begin(); 121 for( QMap<QString,QStringList>::Iterator it = listEntries.begin();
120 it != listEntries.end(); ++it ){ 122 it != listEntries.end(); ++it ){
121 QStringList val = it.data(); 123 QStringList val = it.data();
122 key = it.key(); 124 key = it.key();
123 QChar sep = sepEntries[key]; 125 QChar sep = sepEntries[key];
124// odebug << "saving " << key.latin1() << " -> " << val.join(sep).latin1() << "" << oendl; 126// odebug << "saving " << key.latin1() << " -> " << val.join(sep).latin1() << "" << oendl;
125 keys = QStringList::split( "SEPARATOR", key ); 127 keys = QStringList::split( "SEPARATOR", key );
126 cfg.setGroup(keys[0]); 128 cfg.setGroup(keys[0]);
127 cfg.writeEntry(keys[1], val, sep); 129 cfg.writeEntry(keys[1], val, sep);
128 } 130 }
129} 131}
130 132
131 133
132// 134//
133// cancel changes 135// cancel changes
134// 136//
135void PPPData::cancel() { 137void PPPData::cancel() {
136 stringEntries.clear(); 138 stringEntries.clear();
137 intEntries.clear(); 139 intEntries.clear();
138 listEntries.clear(); 140 listEntries.clear();
139} 141}
140 142
141// functions to read/write date to configuration file 143// functions to read/write date to configuration file
142QString PPPData::readConfig(const QString &group, const QString &key, 144QString PPPData::readConfig(const QString &group, const QString &key,
143 const QString &defvalue = "") 145 const QString &defvalue = "")
144{ 146{
145// odebug << "PPPData::readConfig key >" << key.latin1() << "< group >" << group.latin1() << "<" << oendl; 147// odebug << "PPPData::readConfig key >" << key.latin1() << "< group >" << group.latin1() << "<" << oendl;
146 QString idx = SEP.arg(group).arg(key); 148 QString idx = SEP.arg(group).arg(key);
147 if (stringEntries.find(idx) != stringEntries.end()) 149 if (stringEntries.find(idx) != stringEntries.end())
148 return stringEntries[idx]; 150 return stringEntries[idx];
149 Config cfg = config(); 151 Config cfg = config();
150 cfg.setGroup(group); 152 cfg.setGroup(group);
151 return cfg.readEntry(key, defvalue); 153 return cfg.readEntry(key, defvalue);
152} 154}
153 155
154 156
155int PPPData::readNumConfig(const QString &group, const QString &key, 157int PPPData::readNumConfig(const QString &group, const QString &key,
156 int defvalue) 158 int defvalue)
157{ 159{
158 QString idx = SEP.arg(group).arg(key); 160 QString idx = SEP.arg(group).arg(key);
159 if (intEntries.find(idx) != intEntries.end()) 161 if (intEntries.find(idx) != intEntries.end())
160 return intEntries[idx]; 162 return intEntries[idx];
161 Config cfg = config(); 163 Config cfg = config();
162 cfg.setGroup(group); 164 cfg.setGroup(group);
163 return cfg.readNumEntry(key, defvalue); 165 return cfg.readNumEntry(key, defvalue);
164 166
165// if (config) { 167// if (config) {
166// config->setGroup(group); 168// config->setGroup(group);
167// return config->readNumEntry(key, defvalue); 169// return config->readNumEntry(key, defvalue);
168// } else 170// } else
169// return defvalue; 171// return defvalue;
170 172
171} 173}
172 174
173 175
174bool PPPData::readListConfig(const QString &group, const QString &key, 176bool PPPData::readListConfig(const QString &group, const QString &key,
175 QStringList &list, char sep) { 177 QStringList &list, char sep) {
176 list.clear(); 178 list.clear();
177 QString idx = SEP.arg(group).arg(key); 179 QString idx = SEP.arg(group).arg(key);
178 if (listEntries.find(idx) != listEntries.end()){ 180 if (listEntries.find(idx) != listEntries.end()){
179 list = listEntries[idx]; 181 list = listEntries[idx];
180 return true; 182 return true;
181 } 183 }
182 Config cfg = config(); 184 Config cfg = config();
183 cfg.setGroup(group); 185 cfg.setGroup(group);
184 list = cfg.readListEntry(key, sep); 186 list = cfg.readListEntry(key, sep);
185 if (list.count() > 0) return true; 187 if (list.count() > 0) return true;
186 return false; 188 return false;
187 189
188// if (config) { 190// if (config) {
189// config->setGroup(group); 191// config->setGroup(group);
190// list = config->readListEntry(key, sep); 192// list = config->readListEntry(key, sep);
191// return true; 193// return true;
192// } else 194// } else
193// return false; 195// return false;
194} 196}
195 197
196 198
197void PPPData::writeConfig(const QString &group, const QString &key, 199void PPPData::writeConfig(const QString &group, const QString &key,
198 const QString &value) { 200 const QString &value) {
199 stringEntries.insert( SEP.arg(group).arg(key), value ); 201 stringEntries.insert( SEP.arg(group).arg(key), value );
200// if (config) { 202// if (config) {
201// config->setGroup(group); 203// config->setGroup(group);
202// config->writeEntry(key, value); 204// config->writeEntry(key, value);
203// } 205// }
204} 206}
205 207
206 208
207void PPPData::writeConfig(const QString &group, const QString &key, int value) 209void PPPData::writeConfig(const QString &group, const QString &key, int value)
208{ 210{
209 intEntries.insert( SEP.arg(group).arg(key), value ); 211 intEntries.insert( SEP.arg(group).arg(key), value );
210// if (config) { 212// if (config) {
211// config->setGroup(group); 213// config->setGroup(group);
212// config->writeEntry(key, value); 214// config->writeEntry(key, value);
213// } 215// }
214} 216}
215 217
216 218
217void PPPData::writeListConfig(const QString &group, const QString &key, 219void PPPData::writeListConfig(const QString &group, const QString &key,
218 QStringList &list, char sep) 220 QStringList &list, char sep)
219{ 221{
220 listEntries.insert( SEP.arg(group).arg(key), list ); 222 listEntries.insert( SEP.arg(group).arg(key), list );
221 sepEntries.insert( SEP.arg(group).arg(key), sep ); 223 sepEntries.insert( SEP.arg(group).arg(key), sep );
222// if (config) { 224// if (config) {
223// config->setGroup(group); 225// config->setGroup(group);
224// config->writeEntry(key, list, sep); 226// config->writeEntry(key, list, sep);
225// } 227// }
226} 228}
227 229
228 230
229// 231//
230// functions to set/return general information 232// functions to set/return general information
231// 233//
232QString PPPData::password(){ 234QString PPPData::password(){
233 if ( storePassword() ) return storedPassword(); 235 if ( storePassword() ) return storedPassword();
234 else return passwd; 236 else return passwd;
235} 237}
236 238
237 239
238void PPPData::setPassword(const QString &pw) { 240void PPPData::setPassword(const QString &pw) {
239 passwd = pw; 241 passwd = pw;
240} 242}
241 243
242 244
243const QString PPPData::defaultAccount() { 245const QString PPPData::defaultAccount() {
244 return readConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY); 246 return readConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY);
245} 247}
246 248
247 249
248void PPPData::setDefaultAccount(const QString &n) { 250void PPPData::setDefaultAccount(const QString &n) {
249 writeConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY, n); 251 writeConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY, n);
250 252
251 //now set the current account index to the default account 253 //now set the current account index to the default account
252 setAccount(defaultAccount()); 254 setAccount(defaultAccount());
253} 255}
254 256
255 257
256bool PPPData::get_show_clock_on_caption() { 258bool PPPData::get_show_clock_on_caption() {
257 return (bool) readNumConfig(GENERAL_GRP, SHOWCLOCK_KEY, true); 259 return (bool) readNumConfig(GENERAL_GRP, SHOWCLOCK_KEY, true);
258} 260}
259 261
260 262
261void PPPData::set_show_clock_on_caption(bool set) { 263void PPPData::set_show_clock_on_caption(bool set) {
262 writeConfig(GENERAL_GRP, SHOWCLOCK_KEY, (int) set); 264 writeConfig(GENERAL_GRP, SHOWCLOCK_KEY, (int) set);
263} 265}
264 266
265 267
266bool PPPData::get_xserver_exit_disconnect() { 268bool PPPData::get_xserver_exit_disconnect() {
267 return (bool) readNumConfig(GENERAL_GRP, DISCONNECT_KEY, true); 269 return (bool) readNumConfig(GENERAL_GRP, DISCONNECT_KEY, true);
268} 270}
269 271
270 272
271void PPPData::setPPPDebug(bool set) { 273void PPPData::setPPPDebug(bool set) {
272 writeConfig(GENERAL_GRP, PPP_DEBUG_OPTION, (int)set); 274 writeConfig(GENERAL_GRP, PPP_DEBUG_OPTION, (int)set);
273} 275}
274 276
275 277
276bool PPPData::getPPPDebug() { 278bool PPPData::getPPPDebug() {
277 return (bool)readNumConfig(GENERAL_GRP, PPP_DEBUG_OPTION, false); 279 return (bool)readNumConfig(GENERAL_GRP, PPP_DEBUG_OPTION, false);
278} 280}
279 281
280 282
281void PPPData::set_xserver_exit_disconnect(bool set) { 283void PPPData::set_xserver_exit_disconnect(bool set) {
282 writeConfig(GENERAL_GRP, DISCONNECT_KEY, (int) set); 284 writeConfig(GENERAL_GRP, DISCONNECT_KEY, (int) set);
283} 285}
284 286
285 287
286bool PPPData::quit_on_disconnect() { 288bool PPPData::quit_on_disconnect() {
287 return (bool) readNumConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, false); 289 return (bool) readNumConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, false);
288} 290}
289 291
290 292
291void PPPData::set_quit_on_disconnect(bool set) { 293void PPPData::set_quit_on_disconnect(bool set) {
292 writeConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, (int) set); 294 writeConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, (int) set);
293} 295}
294 296
295 297
296bool PPPData::get_show_log_window() { 298bool PPPData::get_show_log_window() {
297 return (bool) readNumConfig (GENERAL_GRP, SHOWLOGWIN_KEY, false); 299 return (bool) readNumConfig (GENERAL_GRP, SHOWLOGWIN_KEY, false);
298} 300}
299 301
300 302
301void PPPData::set_show_log_window(bool set) { 303void PPPData::set_show_log_window(bool set) {
302 writeConfig(GENERAL_GRP, SHOWLOGWIN_KEY, (int) set); 304 writeConfig(GENERAL_GRP, SHOWLOGWIN_KEY, (int) set);
303} 305}
304 306
305 307
306bool PPPData::automatic_redial() { 308bool PPPData::automatic_redial() {
307 return (bool) readNumConfig(GENERAL_GRP, AUTOREDIAL_KEY, FALSE); 309 return (bool) readNumConfig(GENERAL_GRP, AUTOREDIAL_KEY, FALSE);
308} 310}
309 311
310 312
311void PPPData::set_automatic_redial(bool set) { 313void PPPData::set_automatic_redial(bool set) {
312 writeConfig(GENERAL_GRP, AUTOREDIAL_KEY, (int) set); 314 writeConfig(GENERAL_GRP, AUTOREDIAL_KEY, (int) set);
313} 315}
314 316
315 317
316// bool PPPData::get_iconify_on_connect() { 318// bool PPPData::get_iconify_on_connect() {
317// return (bool) readNumConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, TRUE); 319// return (bool) readNumConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, TRUE);
318// } 320// }
319 321
320 322
321// void PPPData::set_iconify_on_connect(bool set) { 323// void PPPData::set_iconify_on_connect(bool set) {
322// writeConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, (int) set); 324// writeConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, (int) set);
323// } 325// }
324 326
325 327
326// bool PPPData::get_dock_into_panel() { 328// bool PPPData::get_dock_into_panel() {
327// return (bool) readNumConfig(GENERAL_GRP, DOCKING_KEY, false); 329// return (bool) readNumConfig(GENERAL_GRP, DOCKING_KEY, false);
328// } 330// }
329 331
330 332
331// void PPPData::set_dock_into_panel(bool set) { 333// void PPPData::set_dock_into_panel(bool set) {
332// writeConfig(GENERAL_GRP, DOCKING_KEY, (int) set); 334// writeConfig(GENERAL_GRP, DOCKING_KEY, (int) set);
333// } 335// }
334 336
335 337
336QString PPPData::pppdVersion() { 338QString PPPData::pppdVersion() {
337 return QString("%1.%2.%3").arg(pppdVer).arg(pppdMod).arg(pppdPatch); 339 return QString("%1.%2.%3").arg(pppdVer).arg(pppdMod).arg(pppdPatch);
338} 340}
339 341
340bool PPPData::pppdVersionMin(int ver, int mod, int patch) { 342bool PPPData::pppdVersionMin(int ver, int mod, int patch) {
341 // check if pppd version fulfills minimum requirement 343 // check if pppd version fulfills minimum requirement
342 return (pppdVer > ver 344 return (pppdVer > ver
343 || (pppdVer == ver && pppdMod > mod) 345 || (pppdVer == ver && pppdMod > mod)
344 || (pppdVer == ver && pppdMod == mod && pppdPatch >= patch)); 346 || (pppdVer == ver && pppdMod == mod && pppdPatch >= patch));
345} 347}
346 348
347int PPPData::pppdTimeout() { 349int PPPData::pppdTimeout() {
348 return readNumConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, PPPD_TIMEOUT); 350 return readNumConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, PPPD_TIMEOUT);
349} 351}
350 352
351 353
352void PPPData::setpppdTimeout(int n) { 354void PPPData::setpppdTimeout(int n) {
353 writeConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, n); 355 writeConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, n);
354} 356}
355 357
356 358
357const QString PPPData::modemDevice() { 359const QString PPPData::modemDevice() {
358 return readConfig (modemGroup(), MODEMDEV_KEY, "/dev/modem" ); 360 return readConfig (modemGroup(), MODEMDEV_KEY, "/dev/modem" );
359} 361}
360 362
361 363
362// const QString PPPData::modemName() 364// const QString PPPData::modemName()
363// { 365// {
364// return readConfig(modemGroup(), MODEMNAME_KEY); 366// return readConfig(modemGroup(), MODEMNAME_KEY);
365// } 367// }
366 368
367// bool PPPData::setModemName(const QString &n) { 369// bool PPPData::setModemName(const QString &n) {
368// odebug << "Setting modem name to >" << n.latin1() << "<" << oendl; 370// odebug << "Setting modem name to >" << n.latin1() << "<" << oendl;
369// _modemName = n; 371// _modemName = n;
370// writeConfig(cgroup, MODEMNAME_KEY, n); 372// writeConfig(cgroup, MODEMNAME_KEY, n);
371// return true; //FIXME 373// return true; //FIXME
372// } 374// }
373 375
374// bool PPPData::changeModemName(const QString &n) { 376// bool PPPData::changeModemName(const QString &n) {
375// odebug << "Setting modem name to >" << n.latin1() << "<" << oendl; 377// odebug << "Setting modem name to >" << n.latin1() << "<" << oendl;
376// _modemName = n; 378// _modemName = n;
377// writeConfig(modemGroup(), MODEMNAME_KEY, n); 379// writeConfig(modemGroup(), MODEMNAME_KEY, n);
378// return true; //FIXME 380// return true; //FIXME
379// } 381// }
380 382
381bool PPPData::setModemDevice(const QString &n) { 383bool PPPData::setModemDevice(const QString &n) {
382 odebug << "Setting modem dev to >" << n.latin1() << "<" << oendl; 384 odebug << "Setting modem dev to >" << n.latin1() << "<" << oendl;
383 writeConfig(modemGroup(), MODEMDEV_KEY, n); 385 writeConfig(modemGroup(), MODEMDEV_KEY, n);
384 return true; //FIXME 386 return true; //FIXME
385} 387}
386 388
387 389
388const QString PPPData::flowcontrol() { 390const QString PPPData::flowcontrol() {
389 return readConfig(modemGroup(), FLOWCONTROL_KEY, "CRTSCTS"); 391 return readConfig(modemGroup(), FLOWCONTROL_KEY, "CRTSCTS");
390} 392}
391 393
392 394
393void PPPData::setFlowcontrol(const QString &n) { 395void PPPData::setFlowcontrol(const QString &n) {
394 writeConfig(modemGroup(), FLOWCONTROL_KEY, n); 396 writeConfig(modemGroup(), FLOWCONTROL_KEY, n);
395} 397}
396 398
397 399
398const QString PPPData::speed() { 400const QString PPPData::speed() {
399 QString s = readConfig(modemGroup(), SPEED_KEY, "57600"); 401 QString s = readConfig(modemGroup(), SPEED_KEY, "57600");
400 // undo the damage of a bug in former versions. It left an empty Speed= 402 // undo the damage of a bug in former versions. It left an empty Speed=
401 // entry in kppprc. kppp did set the serial port to 57600 as default but 403 // entry in kppprc. kppp did set the serial port to 57600 as default but
402 // pppd wouldn't receive the speed via the command line. 404 // pppd wouldn't receive the speed via the command line.
403 if(s.toUInt() == 0) 405 if(s.toUInt() == 0)
404 s = "57600"; 406 s = "57600";
405 return s; 407 return s;
406} 408}
407 409
408 410
409void PPPData::setSpeed(const QString &n) { 411void PPPData::setSpeed(const QString &n) {
410 writeConfig(modemGroup(), SPEED_KEY, n); 412 writeConfig(modemGroup(), SPEED_KEY, n);
411} 413}
412 414
413 415
414#if 0 416#if 0
415void PPPData::setUseCDLine(const int n) { 417void PPPData::setUseCDLine(const int n) {
416 writeConfig(modemGroup(),USECDLINE_KEY,n); 418 writeConfig(modemGroup(),USECDLINE_KEY,n);
417} 419}
418 420
419 421
420int PPPData::UseCDLine() { 422int PPPData::UseCDLine() {
421 return readNumConfig(modemGroup(),USECDLINE_KEY,0); 423 return readNumConfig(modemGroup(),USECDLINE_KEY,0);
422} 424}
423#endif 425#endif
424 426
425const QString PPPData::modemEscapeStr() { 427const QString PPPData::modemEscapeStr() {
426 return readConfig(modemGroup(),ESCAPESTR_KEY,"+++"); 428 return readConfig(modemGroup(),ESCAPESTR_KEY,"+++");
427} 429}
428 430
429 431
430void PPPData::setModemEscapeStr(const QString &n) { 432void PPPData::setModemEscapeStr(const QString &n) {
431 writeConfig(modemGroup(),ESCAPESTR_KEY,n); 433 writeConfig(modemGroup(),ESCAPESTR_KEY,n);
432} 434}
433 435
434 436
435const QString PPPData::modemEscapeResp() { 437const QString PPPData::modemEscapeResp() {
436 return readConfig(modemGroup(),ESCAPERESP_KEY,"OK"); 438 return readConfig(modemGroup(),ESCAPERESP_KEY,"OK");
437} 439}
438 440
439 441
440void PPPData::setModemEscapeResp(const QString &n) { 442void PPPData::setModemEscapeResp(const QString &n) {
441 writeConfig(modemGroup(),ESCAPERESP_KEY,n); 443 writeConfig(modemGroup(),ESCAPERESP_KEY,n);
442} 444}
443 445
444 446
445int PPPData::modemEscapeGuardTime() { 447int PPPData::modemEscapeGuardTime() {
446 return readNumConfig(modemGroup(),ESCAPEGUARDTIME_KEY,50); 448 return readNumConfig(modemGroup(),ESCAPEGUARDTIME_KEY,50);
447} 449}
448 450
449 451
450void PPPData::setModemEscapeGuardTime(int n) { 452void PPPData::setModemEscapeGuardTime(int n) {
451 writeConfig(modemGroup(),ESCAPEGUARDTIME_KEY,n); 453 writeConfig(modemGroup(),ESCAPEGUARDTIME_KEY,n);
452} 454}
453 455
454 456
455bool PPPData::modemLockFile() { 457bool PPPData::modemLockFile() {
456 return readNumConfig(modemGroup(), LOCKFILE_KEY, 1); 458 return readNumConfig(modemGroup(), LOCKFILE_KEY, 1);
457} 459}
458 460
459 461
460void PPPData::setModemLockFile(bool set) { 462void PPPData::setModemLockFile(bool set) {
461 writeConfig(modemGroup(), LOCKFILE_KEY, set); 463 writeConfig(modemGroup(), LOCKFILE_KEY, set);
462} 464}
463 465
464 466
465int PPPData::modemTimeout() { 467int PPPData::modemTimeout() {
466 return readNumConfig(modemGroup(), TIMEOUT_KEY, MODEM_TIMEOUT); 468 return readNumConfig(modemGroup(), TIMEOUT_KEY, MODEM_TIMEOUT);
467} 469}
468 470
469 471
470void PPPData::setModemTimeout(int n) { 472void PPPData::setModemTimeout(int n) {
471 writeConfig(modemGroup(), TIMEOUT_KEY, n); 473 writeConfig(modemGroup(), TIMEOUT_KEY, n);
472} 474}
473 475
474 476
475int PPPData::modemToneDuration() { 477int PPPData::modemToneDuration() {
476 return readNumConfig(modemGroup(), TONEDURATION_KEY,MODEM_TONEDURATION); 478 return readNumConfig(modemGroup(), TONEDURATION_KEY,MODEM_TONEDURATION);
477} 479}
478 480
479 481
480void PPPData::setModemToneDuration(int n) { 482void PPPData::setModemToneDuration(int n) {
481 writeConfig(modemGroup(), TONEDURATION_KEY, n); 483 writeConfig(modemGroup(), TONEDURATION_KEY, n);
482} 484}
483 485
484 486
485int PPPData::busyWait() { 487int PPPData::busyWait() {
486 return readNumConfig(modemGroup(), BUSYWAIT_KEY, BUSY_WAIT); 488 return readNumConfig(modemGroup(), BUSYWAIT_KEY, BUSY_WAIT);
487} 489}
488 490
489 491
490void PPPData::setbusyWait(int n) { 492void PPPData::setbusyWait(int n) {
491 writeConfig(modemGroup(), BUSYWAIT_KEY, n); 493 writeConfig(modemGroup(), BUSYWAIT_KEY, n);
492} 494}
493 495
494 496
495// 497//
496//Advanced "Modem" dialog 498//Advanced "Modem" dialog
497// 499//
498// defaults: InitString=ATZ, InitString1="" etc. 500// defaults: InitString=ATZ, InitString1="" etc.
499const QString PPPData::modemInitStr(int i) { 501const QString PPPData::modemInitStr(int i) {
500 assert(i >= 0 && i < NumInitStrings); 502 assert(i >= 0 && i < NumInitStrings);
501 if(i == 0) 503 if(i == 0)
502 return readConfig(modemGroup(), INITSTR_KEY, "ATZ"); 504 return readConfig(modemGroup(), INITSTR_KEY, "ATZ");
503 else 505 else
504 return readConfig(modemGroup(), INITSTR_KEY + QString::number(i), ""); 506 return readConfig(modemGroup(), INITSTR_KEY + QString::number(i), "");
505} 507}
506 508
507 509
508void PPPData::setModemInitStr(int i, const QString &n) { 510void PPPData::setModemInitStr(int i, const QString &n) {
509 assert(i >= 0 && i < NumInitStrings); 511 assert(i >= 0 && i < NumInitStrings);
510 QString k = INITSTR_KEY + (i > 0 ? QString::number(i) : QString("")); 512 QString k = INITSTR_KEY + (i > 0 ? QString::number(i) : QString(""));
511 writeConfig(modemGroup(), k, n); 513 writeConfig(modemGroup(), k, n);
512} 514}
513 515
514 516
515const QString PPPData::modemInitResp() { 517const QString PPPData::modemInitResp() {
516 return readConfig(modemGroup(), INITRESP_KEY, "OK"); 518 return readConfig(modemGroup(), INITRESP_KEY, "OK");
517} 519}
518 520
519 521
520void PPPData::setModemInitResp(const QString &n) { 522void PPPData::setModemInitResp(const QString &n) {
521 writeConfig(modemGroup(), INITRESP_KEY, n); 523 writeConfig(modemGroup(), INITRESP_KEY, n);
522} 524}
523 525
524 526
525int PPPData::modemPreInitDelay() { 527int PPPData::modemPreInitDelay() {
526 return readNumConfig(modemGroup(), PREINITDELAY_KEY, 50); 528 return readNumConfig(modemGroup(), PREINITDELAY_KEY, 50);
527} 529}
528 530
529 531
530void PPPData::setModemPreInitDelay(int n) { 532void PPPData::setModemPreInitDelay(int n) {
531 writeConfig(modemGroup(), PREINITDELAY_KEY, n); 533 writeConfig(modemGroup(), PREINITDELAY_KEY, n);
532} 534}
533 535
534 536
535int PPPData::modemInitDelay() { 537int PPPData::modemInitDelay() {
536 return readNumConfig(modemGroup(), INITDELAY_KEY, 50); 538 return readNumConfig(modemGroup(), INITDELAY_KEY, 50);
537} 539}
538 540
539 541
540void PPPData::setModemInitDelay(int n) { 542void PPPData::setModemInitDelay(int n) {
541 writeConfig(modemGroup(), INITDELAY_KEY, n); 543 writeConfig(modemGroup(), INITDELAY_KEY, n);
542} 544}
543 545
544QString PPPData::modemNoDialToneDetectionStr() { 546QString PPPData::modemNoDialToneDetectionStr() {
545 return readConfig(modemGroup(), NODTDETECT_KEY, "ATX3"); 547 return readConfig(modemGroup(), NODTDETECT_KEY, "ATX3");
546} 548}
547 549
548void PPPData::setModemNoDialToneDetectionStr(const QString &n) { 550void PPPData::setModemNoDialToneDetectionStr(const QString &n) {
549 writeConfig(modemGroup(), NODTDETECT_KEY, n); 551 writeConfig(modemGroup(), NODTDETECT_KEY, n);
550} 552}
551 553
552const QString PPPData::modemDialStr() { 554const QString PPPData::modemDialStr() {
553 return readConfig(modemGroup(), DIALSTR_KEY, "ATDT"); 555 return readConfig(modemGroup(), DIALSTR_KEY, "ATDT");
554} 556}
555 557
556 558
557void PPPData::setModemDialStr(const QString &n) { 559void PPPData::setModemDialStr(const QString &n) {
558 writeConfig(modemGroup(), DIALSTR_KEY, n); 560 writeConfig(modemGroup(), DIALSTR_KEY, n);
559} 561}
560 562
561 563
562const QString PPPData::modemConnectResp() { 564const QString PPPData::modemConnectResp() {
563 return readConfig(modemGroup(), CONNECTRESP_KEY, "CONNECT"); 565 return readConfig(modemGroup(), CONNECTRESP_KEY, "CONNECT");
564} 566}
565 567
566 568
567void PPPData::setModemConnectResp(const QString &n) { 569void PPPData::setModemConnectResp(const QString &n) {
568 writeConfig(modemGroup(), CONNECTRESP_KEY, n); 570 writeConfig(modemGroup(), CONNECTRESP_KEY, n);
569} 571}
570 572
571 573
572const QString PPPData::modemBusyResp() { 574const QString PPPData::modemBusyResp() {
573 return readConfig(modemGroup(), BUSYRESP_KEY, "BUSY"); 575 return readConfig(modemGroup(), BUSYRESP_KEY, "BUSY");
574} 576}
575 577
576 578
577void PPPData::setModemBusyResp(const QString &n) { 579void PPPData::setModemBusyResp(const QString &n) {
578 writeConfig(modemGroup(), BUSYRESP_KEY, n); 580 writeConfig(modemGroup(), BUSYRESP_KEY, n);
579} 581}
580 582
581 583
582const QString PPPData::modemNoCarrierResp() { 584const QString PPPData::modemNoCarrierResp() {
583 return readConfig(modemGroup(), NOCARRIERRESP_KEY, "NO CARRIER"); 585 return readConfig(modemGroup(), NOCARRIERRESP_KEY, "NO CARRIER");
584} 586}
585 587
586 588
587void PPPData::setModemNoCarrierResp(const QString &n) { 589void PPPData::setModemNoCarrierResp(const QString &n) {
588 writeConfig(modemGroup(), NOCARRIERRESP_KEY, n); 590 writeConfig(modemGroup(), NOCARRIERRESP_KEY, n);
589} 591}
590 592
591 593
592const QString PPPData::modemNoDialtoneResp() { 594const QString PPPData::modemNoDialtoneResp() {
593 return readConfig(modemGroup(), NODIALTONERESP_KEY, "NO DIALTONE"); 595 return readConfig(modemGroup(), NODIALTONERESP_KEY, "NO DIALTONE");
594} 596}
595 597
596 598
597void PPPData::setModemNoDialtoneResp(const QString &n) { 599void PPPData::setModemNoDialtoneResp(const QString &n) {
598 writeConfig(modemGroup(), NODIALTONERESP_KEY, n); 600 writeConfig(modemGroup(), NODIALTONERESP_KEY, n);
599} 601}
600 602
601 603
602const QString PPPData::modemHangupStr() { 604const QString PPPData::modemHangupStr() {
603 return readConfig(modemGroup(), HANGUPSTR_KEY, "+++ATH"); 605 return readConfig(modemGroup(), HANGUPSTR_KEY, "+++ATH");
604} 606}
605 607
606void PPPData::setModemHangupStr(const QString &n) { 608void PPPData::setModemHangupStr(const QString &n) {
607 writeConfig(modemGroup(), HANGUPSTR_KEY, n); 609 writeConfig(modemGroup(), HANGUPSTR_KEY, n);
608} 610}
609 611
610 612
611const QString PPPData::modemHangupResp() { 613const QString PPPData::modemHangupResp() {
612 return readConfig(modemGroup(), HANGUPRESP_KEY, "OK"); 614 return readConfig(modemGroup(), HANGUPRESP_KEY, "OK");
613} 615}
614 616
615void PPPData::setModemHangupResp(const QString &n) { 617void PPPData::setModemHangupResp(const QString &n) {
616 writeConfig(modemGroup(), HANGUPRESP_KEY, n); 618 writeConfig(modemGroup(), HANGUPRESP_KEY, n);
617} 619}
618 620
619 621
620const QString PPPData::modemAnswerStr() { 622const QString PPPData::modemAnswerStr() {
621 return readConfig(modemGroup(), ANSWERSTR_KEY, "ATA"); 623 return readConfig(modemGroup(), ANSWERSTR_KEY, "ATA");
622} 624}
623 625
624 626
625QString PPPData::volumeOff() { 627QString PPPData::volumeOff() {
626 return readConfig(modemGroup(), VOLUME_OFF, "M0L0"); 628 return readConfig(modemGroup(), VOLUME_OFF, "M0L0");
627} 629}
628 630
629 631
630void PPPData::setVolumeOff(const QString &s) { 632void PPPData::setVolumeOff(const QString &s) {
631 writeConfig(modemGroup(), VOLUME_OFF, s); 633 writeConfig(modemGroup(), VOLUME_OFF, s);
632} 634}
633 635
634 636
635QString PPPData::volumeMedium() { 637QString PPPData::volumeMedium() {
636 return readConfig(modemGroup(), VOLUME_MEDIUM, "M1L1"); 638 return readConfig(modemGroup(), VOLUME_MEDIUM, "M1L1");
637} 639}
638 640
639 641
640void PPPData::setVolumeMedium(const QString &s) { 642void PPPData::setVolumeMedium(const QString &s) {
641 writeConfig(modemGroup(), VOLUME_MEDIUM, s); 643 writeConfig(modemGroup(), VOLUME_MEDIUM, s);
642} 644}
643 645
644 646
645QString PPPData::volumeHigh() { 647QString PPPData::volumeHigh() {
646 QString tmp = readConfig(modemGroup(), VOLUME_HIGH, "M1L3"); 648 QString tmp = readConfig(modemGroup(), VOLUME_HIGH, "M1L3");
647 if(tmp == "M1L4") 649 if(tmp == "M1L4")
648 tmp = "M1L3"; 650 tmp = "M1L3";
649 return tmp; 651 return tmp;
650} 652}
651 653
652 654
653void PPPData::setVolumeHigh(const QString &s) { 655void PPPData::setVolumeHigh(const QString &s) {
654 writeConfig(modemGroup(), VOLUME_HIGH, s); 656 writeConfig(modemGroup(), VOLUME_HIGH, s);
655} 657}
656 658
657 659
658QString PPPData::volumeInitString() { 660QString PPPData::volumeInitString() {
659 QString s; 661 QString s;
660 662
661 switch(volume()) { 663 switch(volume()) {
662 case 0: 664 case 0:
663 s = volumeOff(); 665 s = volumeOff();
664 break; 666 break;
665 case 1: 667 case 1:
666 s = volumeMedium(); 668 s = volumeMedium();
667 break; 669 break;
668 case 2: 670 case 2:
669 s = volumeHigh(); 671 s = volumeHigh();
670 break; 672 break;
671 default: 673 default:
672 s = volumeMedium(); 674 s = volumeMedium();
673 } 675 }
674 676
675 return s; 677 return s;
676} 678}
677 679
678 680
679int PPPData::volume() { 681int PPPData::volume() {
680 return readNumConfig(modemGroup(), VOLUME_KEY, 1); 682 return readNumConfig(modemGroup(), VOLUME_KEY, 1);
681} 683}
682 684
683 685
684void PPPData::setVolume(int i) { 686void PPPData::setVolume(int i) {
685 writeConfig(modemGroup(), VOLUME_KEY, i); 687 writeConfig(modemGroup(), VOLUME_KEY, i);
686} 688}
687 689
688int PPPData::waitForDialTone() { 690int PPPData::waitForDialTone() {
689 return readNumConfig(modemGroup(), DIALTONEWAIT_KEY, 1); 691 return readNumConfig(modemGroup(), DIALTONEWAIT_KEY, 1);
690} 692}
691 693
692void PPPData::setWaitForDialTone(int i) { 694void PPPData::setWaitForDialTone(int i) {
693 writeConfig(modemGroup(), DIALTONEWAIT_KEY, i); 695 writeConfig(modemGroup(), DIALTONEWAIT_KEY, i);
694} 696}
695 697
696void PPPData::setModemAnswerStr(const QString &n) { 698void PPPData::setModemAnswerStr(const QString &n) {
697 writeConfig(modemGroup(), ANSWERSTR_KEY, n); 699 writeConfig(modemGroup(), ANSWERSTR_KEY, n);
698} 700}
699 701
700 702
701const QString PPPData::modemRingResp() { 703const QString PPPData::modemRingResp() {
702 return readConfig(modemGroup(), RINGRESP_KEY, "RING"); 704 return readConfig(modemGroup(), RINGRESP_KEY, "RING");
703} 705}
704 706
705 707
706void PPPData::setModemRingResp(const QString &n) { 708void PPPData::setModemRingResp(const QString &n) {
707 writeConfig(modemGroup(), RINGRESP_KEY, n); 709 writeConfig(modemGroup(), RINGRESP_KEY, n);
708} 710}
709 711
710 712
711const QString PPPData::modemAnswerResp() { 713const QString PPPData::modemAnswerResp() {
712 return readConfig(modemGroup(), ANSWERRESP_KEY, "CONNECT"); 714 return readConfig(modemGroup(), ANSWERRESP_KEY, "CONNECT");
713} 715}
714 716
715 717
716void PPPData::setModemAnswerResp(const QString &n) { 718void PPPData::setModemAnswerResp(const QString &n) {
717 writeConfig(modemGroup(), ANSWERRESP_KEY, n); 719 writeConfig(modemGroup(), ANSWERRESP_KEY, n);
718} 720}
719 721
720 722
721const QString PPPData::enter() { 723const QString PPPData::enter() {
722 return readConfig(modemGroup(), ENTER_KEY, "CR"); 724 return readConfig(modemGroup(), ENTER_KEY, "CR");
723} 725}
724 726
725 727
726void PPPData::setEnter(const QString &n) { 728void PPPData::setEnter(const QString &n) {
727 writeConfig(modemGroup(), ENTER_KEY, n); 729 writeConfig(modemGroup(), ENTER_KEY, n);
728} 730}
729 731
730 732
731// 733//
732// functions to set/return account information 734// functions to set/return account information
733// 735//
734 736
735//returns number of accounts 737//returns number of accounts
736int PPPData::count() const { 738int PPPData::count() const {
737 return highcount + 1; 739 return highcount + 1;
738} 740}
739 741
740 742
741bool PPPData::setAccount(const QString &aname) { 743bool PPPData::setAccount(const QString &aname) {
742 odebug << "setting account to >" << aname.latin1() << "<" << oendl; 744 odebug << "setting account to >" << aname.latin1() << "<" << oendl;
743 for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) { 745 for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) {
744 cgroup = *it; 746 cgroup = *it;
745 odebug << "PPPData::setAccount " << cgroup.latin1() << "" << oendl; 747 odebug << "PPPData::setAccount " << cgroup.latin1() << "" << oendl;
746 odebug << "iterator " << (*it).latin1() << "" << oendl; 748 odebug << "iterator " << (*it).latin1() << "" << oendl;
747 if(accname() == aname) { 749 if(accname() == aname) {
748 odebug << "SUCCESS" << oendl; 750 odebug << "SUCCESS" << oendl;
749 return true; 751 return true;
750 } 752 }
751 753
752 } 754 }
753 odebug << "FAILURE" << oendl; 755 odebug << "FAILURE" << oendl;
754 return false; 756 return false;
755} 757}
756 758
757/* 759/*
758bool PPPData::setAccountbyIndex(int i) { 760bool PPPData::setAccountbyIndex(int i) {
759 if(i >= 0 && i <= highcount) { 761 if(i >= 0 && i <= highcount) {
760 QString tmp; 762 QString tmp;
761 tmp.sprintf("%s%i", ACCOUNT_GRP, i); 763 tmp.sprintf("%s%i", ACCOUNT_GRP, i);
762 if (_deleted.find(tmp)!=_deleted.end()) return false; 764 if (_deleted.find(tmp)!=_deleted.end()) return false;
763 caccount = i; 765 caccount = i;
764 cgroup = tmp; 766 cgroup = tmp;
765 return true; 767 return true;
766 } 768 }
767 return false; 769 return false;
768} 770}
769*/ 771*/
770 772
771bool PPPData::isUniqueAccname(const QString &n) { 773bool PPPData::isUniqueAccname(const QString &n) {
772 QString save_cgroup = cgroup; 774 QString save_cgroup = cgroup;
773 for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) { 775 for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) {
774 cgroup = *it; 776 cgroup = *it;
775 odebug << "PPPData::setAccount " << cgroup.latin1() << "" << oendl; 777 odebug << "PPPData::setAccount " << cgroup.latin1() << "" << oendl;
776 odebug << "" << (*it).latin1() << " \n" << oendl; 778 odebug << "" << (*it).latin1() << " \n" << oendl;
777 if(accname() == n && cgroup != save_cgroup) { 779 if(accname() == n && cgroup != save_cgroup) {
778 cgroup = save_cgroup; 780 cgroup = save_cgroup;
779 odebug << "SUCCESS" << oendl; 781 odebug << "SUCCESS" << oendl;
780 return false; 782 return false;
781 } 783 }
782 784
783 } 785 }
784 cgroup = save_cgroup; 786 cgroup = save_cgroup;
785 return true; 787 return true;
786} 788}
787 789
788 790
789bool PPPData::isUniqueDevname(const QString &n) { 791bool PPPData::isUniqueDevname(const QString &n) {
790 QString save_mName = _modemName; 792 QString save_mName = _modemName;
791 odebug << "PPPData::isUniqueDevname checking if " << n.latin1() << " is unique" << oendl; 793 odebug << "PPPData::isUniqueDevname checking if " << n.latin1() << " is unique" << oendl;
792 for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) { 794 for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) {
793 _modemName = *it; 795 _modemName = *it;
794 odebug << "PPPData::isUniqueDevname " << n.latin1() << " == " << devname().latin1() << "" << oendl; 796 odebug << "PPPData::isUniqueDevname " << n.latin1() << " == " << devname().latin1() << "" << oendl;
795 if(devname() == n && _modemName != save_mName) { 797 if(devname() == n && _modemName != save_mName) {
796 _modemName = save_mName; 798 _modemName = save_mName;
797 odebug << "NOT UNIQUE" << oendl; 799 odebug << "NOT UNIQUE" << oendl;
798 return false; 800 return false;
799 } 801 }
800 802
801 } 803 }
802 _modemName = save_mName; 804 _modemName = save_mName;
803 return true; 805 return true;
804} 806}
805 807
806 808
807bool PPPData::deleteAccount() { 809bool PPPData::deleteAccount() {
808 // FIXME: check if this account exists in a config... 810 // FIXME: check if this account exists in a config...
809 Config cfg = PPPData::config(); 811 Config cfg = PPPData::config();
810 cfg.setGroup(cgroup); 812 cfg.setGroup(cgroup);
811 cfg.clearGroup(); 813 cfg.clearGroup();
812 accountList.remove(cgroup); 814 accountList.remove(cgroup);
813 815
814 QString key; 816 QString key;
815 QStringList keys; 817 QStringList keys;
816 for( QMap<QString,QString>::Iterator it = stringEntries.begin(); 818 for( QMap<QString,QString>::Iterator it = stringEntries.begin();
817 it != stringEntries.end(); ++it ){ 819 it != stringEntries.end(); ++it ){
818 QString val = it.data(); 820 QString val = it.data();
819 key = it.key(); 821 key = it.key();
820 keys = QStringList::split( "SEPARATOR", key ); 822 keys = QStringList::split( "SEPARATOR", key );
821 if(keys[0]==cgroup){ 823 if(keys[0]==cgroup){
822 stringEntries.remove( it ); 824 stringEntries.remove( it );
823 odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.latin1() << "<" << oendl; 825 odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.latin1() << "<" << oendl;
824 } 826 }
825 } 827 }
826 for( QMap<QString,int>::Iterator it = intEntries.begin(); 828 for( QMap<QString,int>::Iterator it = intEntries.begin();
827 it != intEntries.end(); ++it ){ 829 it != intEntries.end(); ++it ){
828 int val = it.data(); 830 int val = it.data();
829 key = it.key(); 831 key = it.key();
830 keys = QStringList::split( "SEPARATOR", key ); 832 keys = QStringList::split( "SEPARATOR", key );
831 if(keys[0]==cgroup){ 833 if(keys[0]==cgroup){
832 intEntries.remove( it ); 834 intEntries.remove( it );
833 odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val << "<" << oendl; 835 odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val << "<" << oendl;
834 } 836 }
835 } 837 }
836 for( QMap<QString,QStringList>::Iterator it = listEntries.begin(); 838 for( QMap<QString,QStringList>::Iterator it = listEntries.begin();
837 it != listEntries.end(); ++it ){ 839 it != listEntries.end(); ++it ){
838 QStringList val = it.data(); 840 QStringList val = it.data();
839 key = it.key(); 841 key = it.key();
840 if(keys[0]==cgroup){ 842 if(keys[0]==cgroup){
841 listEntries.remove( it ); 843 listEntries.remove( it );
842 sepEntries.remove( key ); 844 sepEntries.remove( key );
843 odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.join("").latin1() << "<" << oendl; 845 odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.join("").latin1() << "<" << oendl;
844 } 846 }
845 } 847 }
846 848
847 return true; 849 return true;
848} 850}
849 851
850 852
851bool PPPData::deleteAccount(const QString &aname) { 853bool PPPData::deleteAccount(const QString &aname) {
852 if(!setAccount(aname)) 854 if(!setAccount(aname))
853 return false; 855 return false;
854 856
855 deleteAccount(); 857 deleteAccount();
856 858
857 return true; 859 return true;
858} 860}
859 861
860 862
861int PPPData::newaccount() { 863int PPPData::newaccount() {
862 864
863 odebug << "PPPData::newaccount highcount " << highcount << "/" << MAX_ACCOUNTS << "" << oendl; 865 odebug << "PPPData::newaccount highcount " << highcount << "/" << MAX_ACCOUNTS << "" << oendl;
864// if(!config) open(); 866// if(!config) open();
865// if (highcount >= MAX_ACCOUNTS) return -1; 867// if (highcount >= MAX_ACCOUNTS) return -1;
866 868
867 869
868 QString tmp; 870 QString tmp;
869 tmp.sprintf("%s%i", ACCOUNT_GRP, ++highcount); 871 tmp.sprintf("%s%i", ACCOUNT_GRP, ++highcount);
870 cgroup = QString(tmp); 872 cgroup = QString(tmp);
871 accountList << tmp; 873 accountList << tmp;
872 odebug << "PPPData::newaccount() Group: >" << cgroup.latin1() << "<" << oendl; 874 odebug << "PPPData::newaccount() Group: >" << cgroup.latin1() << "<" << oendl;
873 setpppdArgumentDefaults(); 875 setpppdArgumentDefaults();
874 return highcount; 876 return highcount;
875} 877}
876 878
877int PPPData::copyaccount(const QString&) { 879int PPPData::copyaccount(const QString&) {
878// FIXME: PPPData::copyaccount 880// FIXME: PPPData::copyaccount
879// if(highcount >= MAX_ACCOUNTS) 881// if(highcount >= MAX_ACCOUNTS)
880 return -1; 882 return -1;
881 883
882// setAccountbyIndex(i); 884// setAccountbyIndex(i);
883 885
884// QMap <QString, QString> map = config->entryMap(cgroup); 886// QMap <QString, QString> map = config->entryMap(cgroup);
885// QMap <QString, QString>::ConstIterator it = map.begin(); 887// QMap <QString, QString>::ConstIterator it = map.begin();
886 888
887// QString newname = QObject::tr("%1_copy").arg(accname()); 889// QString newname = QObject::tr("%1_copy").arg(accname());
888 890
889// newaccount(); 891// newaccount();
890 892
891// while (it != map.end()) { 893// while (it != map.end()) {
892// config->writeEntry(it.key(), *it); 894// config->writeEntry(it.key(), *it);
893// it++; 895// it++;
894// } 896// }
895 897
896// setAccname(newname); 898// setAccname(newname);
897 899
898// return caccount; 900// return caccount;
899} 901}
900 902
901 903
902const QString PPPData::accname() { 904const QString PPPData::accname() {
903 return readConfig(cgroup, NAME_KEY); 905 return readConfig(cgroup, NAME_KEY);
904} 906}
905 907
906void PPPData::setAccname(const QString &n) { 908void PPPData::setAccname(const QString &n) {
907 if(!cgroup.isNull()) { 909 if(!cgroup.isNull()) {
908 // are we manipulating the default account's name ? then change it, too. 910 // are we manipulating the default account's name ? then change it, too.
909 bool def = accname() == defaultAccount(); 911 bool def = accname() == defaultAccount();
910 writeConfig(cgroup, NAME_KEY, n); 912 writeConfig(cgroup, NAME_KEY, n);
911 if (def) 913 if (def)
912 setDefaultAccount(n); 914 setDefaultAccount(n);
913 } 915 }
914 writeConfig(cgroup, NAME_KEY, n); 916 writeConfig(cgroup, NAME_KEY, n);
915} 917}
916 918
917 919
918#define SEPARATOR_CHAR '&' 920#define SEPARATOR_CHAR '&'
919QStringList &PPPData::phonenumbers() { 921QStringList &PPPData::phonenumbers() {
920 922
921 readListConfig(cgroup, PHONENUMBER_KEY, phonelist, SEPARATOR_CHAR); 923 readListConfig(cgroup, PHONENUMBER_KEY, phonelist, SEPARATOR_CHAR);
922 return phonelist; 924 return phonelist;
923 925
924} 926}
925 927
926 928
927const QString PPPData::phonenumber() { 929const QString PPPData::phonenumber() {
928 return readConfig(cgroup, PHONENUMBER_KEY); 930 return readConfig(cgroup, PHONENUMBER_KEY);
929} 931}
930 932
931 933
932void PPPData::setPhonenumber(const QString &n) { 934void PPPData::setPhonenumber(const QString &n) {
933 writeConfig(cgroup, PHONENUMBER_KEY, n); 935 writeConfig(cgroup, PHONENUMBER_KEY, n);
934} 936}
935 937
936 938
937const QString PPPData::dialPrefix() { 939const QString PPPData::dialPrefix() {
938 return readConfig(cgroup, DIAL_PREFIX_KEY, ""); 940 return readConfig(cgroup, DIAL_PREFIX_KEY, "");
939} 941}
940 942
941 943
942void PPPData::setDialPrefix(const QString &s) { 944void PPPData::setDialPrefix(const QString &s) {
943 writeConfig(cgroup, DIAL_PREFIX_KEY, s); 945 writeConfig(cgroup, DIAL_PREFIX_KEY, s);
944} 946}
945 947
946 948
947int PPPData::authMethod() { 949int PPPData::authMethod() {
948 return readNumConfig(cgroup, AUTH_KEY, 0); 950 return readNumConfig(cgroup, AUTH_KEY, 0);
949} 951}
950 952
951 953
952void PPPData::setAuthMethod(int value) { 954void PPPData::setAuthMethod(int value) {
953 writeConfig(cgroup, AUTH_KEY, value); 955 writeConfig(cgroup, AUTH_KEY, value);
954} 956}
955 957
956 958
957const QString PPPData::storedUsername() { 959const QString PPPData::storedUsername() {
958 return readConfig(cgroup, STORED_USERNAME_KEY, ""); 960 return readConfig(cgroup, STORED_USERNAME_KEY, "");
959} 961}
960 962
961 963
962void PPPData::setStoredUsername(const QString &b) { 964void PPPData::setStoredUsername(const QString &b) {
963 writeConfig(cgroup, STORED_USERNAME_KEY, b); 965 writeConfig(cgroup, STORED_USERNAME_KEY, b);
964} 966}
965 967
966 968
967const QString PPPData::storedPassword() { 969const QString PPPData::storedPassword() {
968 odebug << "getting stored pw" << oendl; 970 odebug << "getting stored pw" << oendl;
969 odebug << "g " << cgroup.latin1() << "" << oendl; 971 odebug << "g " << cgroup.latin1() << "" << oendl;
970 odebug << "k " << STORED_PASSWORD_KEY << "" << oendl; 972 odebug << "k " << STORED_PASSWORD_KEY << "" << oendl;
971 return readConfig(cgroup, STORED_PASSWORD_KEY, ""); 973 return readConfig(cgroup, STORED_PASSWORD_KEY, "");
972} 974}
973 975
974 976
975void PPPData::setStoredPassword(const QString &b) { 977void PPPData::setStoredPassword(const QString &b) {
976 writeConfig(cgroup, STORED_PASSWORD_KEY, b); 978 writeConfig(cgroup, STORED_PASSWORD_KEY, b);
977} 979}
978 980
979 981
980bool PPPData::storePassword() { 982bool PPPData::storePassword() {
981 return (bool)readNumConfig(cgroup, STORE_PASSWORD_KEY, 1); 983 return (bool)readNumConfig(cgroup, STORE_PASSWORD_KEY, 1);
982} 984}
983 985
984 986
985const QString PPPData::command_before_connect() { 987const QString PPPData::command_before_connect() {
986 return readConfig(cgroup, BEFORE_CONNECT_KEY); 988 return readConfig(cgroup, BEFORE_CONNECT_KEY);
987} 989}
988 990
989 991
990void PPPData::setCommand_before_connect(const QString &n) { 992void PPPData::setCommand_before_connect(const QString &n) {
991 writeConfig(cgroup, BEFORE_CONNECT_KEY, n); 993 writeConfig(cgroup, BEFORE_CONNECT_KEY, n);
992} 994}
993 995
994 996
995void PPPData::setStorePassword(bool b) { 997void PPPData::setStorePassword(bool b) {
996 writeConfig(cgroup, STORE_PASSWORD_KEY, (int)b); 998 writeConfig(cgroup, STORE_PASSWORD_KEY, (int)b);
997} 999}
998 1000
999 1001
1000const QString PPPData::command_on_connect() { 1002const QString PPPData::command_on_connect() {
1001 return readConfig(cgroup, COMMAND_KEY); 1003 return readConfig(cgroup, COMMAND_KEY);
1002} 1004}
1003 1005
1004 1006
1005void PPPData::setCommand_on_connect(const QString &n) { 1007void PPPData::setCommand_on_connect(const QString &n) {
1006 writeConfig(cgroup, COMMAND_KEY, n); 1008 writeConfig(cgroup, COMMAND_KEY, n);
1007} 1009}
1008 1010
1009 1011
1010const QString PPPData::command_on_disconnect() { 1012const QString PPPData::command_on_disconnect() {
1011 return readConfig(cgroup, DISCONNECT_COMMAND_KEY); 1013 return readConfig(cgroup, DISCONNECT_COMMAND_KEY);
1012} 1014}
1013 1015
1014 1016
1015void PPPData::setCommand_on_disconnect(const QString &n) { 1017void PPPData::setCommand_on_disconnect(const QString &n) {
1016 writeConfig(cgroup, DISCONNECT_COMMAND_KEY, n); 1018 writeConfig(cgroup, DISCONNECT_COMMAND_KEY, n);
1017} 1019}
1018 1020
1019 1021
1020const QString PPPData::command_before_disconnect() { 1022const QString PPPData::command_before_disconnect() {
1021 return readConfig(cgroup, BEFORE_DISCONNECT_KEY); 1023 return readConfig(cgroup, BEFORE_DISCONNECT_KEY);
1022} 1024}
1023 1025
1024 1026
1025void PPPData::setCommand_before_disconnect(const QString &n) { 1027void PPPData::setCommand_before_disconnect(const QString &n) {
1026 writeConfig(cgroup, BEFORE_DISCONNECT_KEY, n); 1028 writeConfig(cgroup, BEFORE_DISCONNECT_KEY, n);
1027} 1029}
1028 1030
1029 1031
1030const QString PPPData::ipaddr() { 1032const QString PPPData::ipaddr() {
1031 return readConfig(cgroup, IPADDR_KEY); 1033 return readConfig(cgroup, IPADDR_KEY);
1032} 1034}
1033 1035
1034 1036
1035void PPPData::setIpaddr(const QString &n) { 1037void PPPData::setIpaddr(const QString &n) {
1036 writeConfig(cgroup, IPADDR_KEY, n); 1038 writeConfig(cgroup, IPADDR_KEY, n);
1037} 1039}
1038 1040
1039 1041
1040const QString PPPData::subnetmask() { 1042const QString PPPData::subnetmask() {
1041 return readConfig(cgroup, SUBNETMASK_KEY); 1043 return readConfig(cgroup, SUBNETMASK_KEY);
1042} 1044}
1043 1045
1044 1046
1045void PPPData::setSubnetmask(const QString &n) { 1047void PPPData::setSubnetmask(const QString &n) {
1046 writeConfig(cgroup, SUBNETMASK_KEY, n); 1048 writeConfig(cgroup, SUBNETMASK_KEY, n);
1047} 1049}
1048 1050
1049 1051
1050bool PPPData::autoname() { 1052bool PPPData::autoname() {
1051 return (bool) readNumConfig(cgroup, AUTONAME_KEY, false); 1053 return (bool) readNumConfig(cgroup, AUTONAME_KEY, false);
1052} 1054}
1053 1055
1054 1056
1055void PPPData::setAutoname(bool set) { 1057void PPPData::setAutoname(bool set) {
1056 writeConfig(cgroup, AUTONAME_KEY, (int) set); 1058 writeConfig(cgroup, AUTONAME_KEY, (int) set);
1057} 1059}
1058 1060
1059 1061
1060bool PPPData::AcctEnabled() { 1062bool PPPData::AcctEnabled() {
1061 return (bool) readNumConfig(cgroup, ACCTENABLED_KEY, false); 1063 return (bool) readNumConfig(cgroup, ACCTENABLED_KEY, false);
1062} 1064}
1063 1065
1064 1066
1065void PPPData::setAcctEnabled(bool set) { 1067void PPPData::setAcctEnabled(bool set) {
1066 writeConfig(cgroup, ACCTENABLED_KEY, (int) set); 1068 writeConfig(cgroup, ACCTENABLED_KEY, (int) set);
1067} 1069}
1068 1070
1069 1071
1070// int PPPData::VolAcctEnabled() { 1072// int PPPData::VolAcctEnabled() {
1071// return readNumConfig(cgroup, VOLACCTENABLED_KEY, 0); 1073// return readNumConfig(cgroup, VOLACCTENABLED_KEY, 0);
1072// } 1074// }
1073 1075
1074 1076
1075// void PPPData::setVolAcctEnabled(int set) { 1077// void PPPData::setVolAcctEnabled(int set) {
1076// writeConfig(cgroup, VOLACCTENABLED_KEY, set); 1078// writeConfig(cgroup, VOLACCTENABLED_KEY, set);
1077// } 1079// }
1078 1080
1079 1081
1080const QString PPPData::gateway() { 1082const QString PPPData::gateway() {
1081 return readConfig(cgroup, GATEWAY_KEY); 1083 return readConfig(cgroup, GATEWAY_KEY);
1082} 1084}
1083 1085
1084 1086
1085void PPPData::setGateway(const QString &n ) { 1087void PPPData::setGateway(const QString &n ) {
1086 writeConfig(cgroup, GATEWAY_KEY, n); 1088 writeConfig(cgroup, GATEWAY_KEY, n);
1087} 1089}
1088 1090
1089 1091
1090bool PPPData::defaultroute() { 1092bool PPPData::defaultroute() {
1091 // default route is by default 'on'. 1093 // default route is by default 'on'.
1092 return (bool) readNumConfig(cgroup, DEFAULTROUTE_KEY, true); 1094 return (bool) readNumConfig(cgroup, DEFAULTROUTE_KEY, true);
1093} 1095}
1094 1096
1095 1097
1096void PPPData::setDefaultroute(bool set) { 1098void PPPData::setDefaultroute(bool set) {
1097 writeConfig(cgroup, DEFAULTROUTE_KEY, (int) set); 1099 writeConfig(cgroup, DEFAULTROUTE_KEY, (int) set);
1098} 1100}
1099 1101
1100 1102
1101bool PPPData::autoDNS() { 1103bool PPPData::autoDNS() {
1102 bool set = (bool) readNumConfig(cgroup, AUTODNS_KEY, true); 1104 bool set = (bool) readNumConfig(cgroup, AUTODNS_KEY, true);
1103 return (set && pppdVersionMin(2, 3, 7)); 1105 return (set && pppdVersionMin(2, 3, 7));
1104} 1106}
1105 1107
1106 1108
1107void PPPData::setAutoDNS(bool set) { 1109void PPPData::setAutoDNS(bool set) {
1108 writeConfig(cgroup, AUTODNS_KEY, (int) set); 1110 writeConfig(cgroup, AUTODNS_KEY, (int) set);
1109} 1111}
1110 1112
1111 1113
1112void PPPData::setExDNSDisabled(bool set) { 1114void PPPData::setExDNSDisabled(bool set) {
1113 writeConfig(cgroup, EXDNSDISABLED_KEY, (int) set); 1115 writeConfig(cgroup, EXDNSDISABLED_KEY, (int) set);
1114} 1116}
1115 1117
1116 1118
1117bool PPPData::exDNSDisabled() { 1119bool PPPData::exDNSDisabled() {
1118 return (bool) readNumConfig(cgroup, EXDNSDISABLED_KEY,0); 1120 return (bool) readNumConfig(cgroup, EXDNSDISABLED_KEY,0);
1119} 1121}
1120 1122
1121 1123
1122QStringList &PPPData::dns() { 1124QStringList &PPPData::dns() {
1123 static QStringList dnslist; 1125 static QStringList dnslist;
1124 1126
1125 readListConfig(cgroup, DNS_KEY, dnslist); 1127 readListConfig(cgroup, DNS_KEY, dnslist);
1126 while(dnslist.count() > MAX_DNS_ENTRIES) 1128 while(dnslist.count() > MAX_DNS_ENTRIES)
1127 dnslist.remove(dnslist.last()); 1129 dnslist.remove(dnslist.last());
1128 1130
1129 return dnslist; 1131 return dnslist;
1130} 1132}
1131 1133
1132 1134
1133void PPPData::setDns(QStringList &list) { 1135void PPPData::setDns(QStringList &list) {
1134 writeListConfig(cgroup, DNS_KEY, list); 1136 writeListConfig(cgroup, DNS_KEY, list);
1135} 1137}
1136 1138
1137 1139
1138const QString PPPData::domain() { 1140const QString PPPData::domain() {
1139 return readConfig(cgroup, DOMAIN_KEY); 1141 return readConfig(cgroup, DOMAIN_KEY);
1140} 1142}
1141 1143
1142 1144
1143void PPPData::setDomain(const QString &n ) { 1145void PPPData::setDomain(const QString &n ) {
1144 writeConfig(cgroup, DOMAIN_KEY, n); 1146 writeConfig(cgroup, DOMAIN_KEY, n);
1145} 1147}
1146 1148
1147 1149
1148QStringList &PPPData::scriptType() { 1150QStringList &PPPData::scriptType() {
1149 static QStringList typelist; 1151 static QStringList typelist;
1150 1152
1151 readListConfig(cgroup, SCRIPTCOM_KEY, typelist); 1153 readListConfig(cgroup, SCRIPTCOM_KEY, typelist);
1152 while(typelist.count() > MAX_SCRIPT_ENTRIES) 1154 while(typelist.count() > MAX_SCRIPT_ENTRIES)
1153 typelist.remove(typelist.last()); 1155 typelist.remove(typelist.last());
1154 1156
1155 return typelist; 1157 return typelist;
1156} 1158}
1157 1159
1158 1160
1159void PPPData::setScriptType(QStringList &list) { 1161void PPPData::setScriptType(QStringList &list) {
1160 writeListConfig(cgroup, SCRIPTCOM_KEY, list); 1162 writeListConfig(cgroup, SCRIPTCOM_KEY, list);
1161} 1163}
1162 1164
1163 1165
1164QStringList &PPPData::script() { 1166QStringList &PPPData::script() {
1165 static QStringList scriptlist; 1167 static QStringList scriptlist;
1166 1168
1167 readListConfig(cgroup, SCRIPTARG_KEY, scriptlist); 1169 readListConfig(cgroup, SCRIPTARG_KEY, scriptlist);
1168 while(scriptlist.count() > MAX_SCRIPT_ENTRIES) 1170 while(scriptlist.count() > MAX_SCRIPT_ENTRIES)
1169 scriptlist.remove(scriptlist.last()); 1171 scriptlist.remove(scriptlist.last());
1170 1172
1171 return scriptlist; 1173 return scriptlist;
1172} 1174}
1173 1175
1174 1176
1175void PPPData::setScript(QStringList &list) { 1177void PPPData::setScript(QStringList &list) {
1176 writeListConfig(cgroup, SCRIPTARG_KEY, list); 1178 writeListConfig(cgroup, SCRIPTARG_KEY, list);
1177} 1179}
1178 1180
1179 1181
1180// const QString PPPData::accountingFile() { 1182// const QString PPPData::accountingFile() {
1181// return readConfig(cgroup, ACCTFILE_KEY); 1183// return readConfig(cgroup, ACCTFILE_KEY);
1182// } 1184// }
1183 1185
1184 1186
1185// void PPPData::setAccountingFile(const QString &n) { 1187// void PPPData::setAccountingFile(const QString &n) {
1186// writeConfig(cgroup, ACCTFILE_KEY, n); 1188// writeConfig(cgroup, ACCTFILE_KEY, n);
1187// } 1189// }
1188 1190
1189 1191
1190// const QString PPPData::totalCosts() { 1192// const QString PPPData::totalCosts() {
1191// return readConfig(cgroup, TOTALCOSTS_KEY); 1193// return readConfig(cgroup, TOTALCOSTS_KEY);
1192// } 1194// }
1193 1195
1194 1196
1195// void PPPData::setTotalCosts(const QString &n) { 1197// void PPPData::setTotalCosts(const QString &n) {
1196// writeConfig(cgroup, TOTALCOSTS_KEY, n); 1198// writeConfig(cgroup, TOTALCOSTS_KEY, n);
1197// } 1199// }
1198 1200
1199 1201
1200// int PPPData::totalBytes() { 1202// int PPPData::totalBytes() {
1201// return readNumConfig(cgroup, TOTALBYTES_KEY, 0); 1203// return readNumConfig(cgroup, TOTALBYTES_KEY, 0);
1202// } 1204// }
1203 1205
1204// void PPPData::setTotalBytes(int n) { 1206// void PPPData::setTotalBytes(int n) {
1205// writeConfig(cgroup, TOTALBYTES_KEY, n); 1207// writeConfig(cgroup, TOTALBYTES_KEY, n);
1206// } 1208// }
1207 1209
1208 1210
1209QStringList &PPPData::pppdArgument() { 1211QStringList &PPPData::pppdArgument() {
1210 static QStringList arglist; 1212 static QStringList arglist;
1211 1213
1212 while(arglist.count() > MAX_PPPD_ARGUMENTS) 1214 while(arglist.count() > MAX_PPPD_ARGUMENTS)
1213 arglist.remove(arglist.last()); 1215 arglist.remove(arglist.last());
1214 readListConfig(cgroup, PPPDARG_KEY, arglist); 1216 readListConfig(cgroup, PPPDARG_KEY, arglist);
1215 1217
1216 return arglist; 1218 return arglist;
1217} 1219}
1218 1220
1219 1221
1220void PPPData::setpppdArgument(QStringList &args) { 1222void PPPData::setpppdArgument(QStringList &args) {
1221 writeListConfig(cgroup, PPPDARG_KEY, args); 1223 writeListConfig(cgroup, PPPDARG_KEY, args);
1222} 1224}
1223 1225
1224 1226
1225void PPPData::setpppdArgumentDefaults() { 1227void PPPData::setpppdArgumentDefaults() {
1226 QStringList arg; 1228 QStringList arg;
1227 arg << "lcp-echo-failure 0"; 1229 arg << "lcp-echo-failure 0";
1228 setpppdArgument(arg); 1230 setpppdArgument(arg);
1229} 1231}
1230 1232
1231 1233
1232// // graphing widget 1234// // graphing widget
1233// void PPPData::setGraphingOptions(bool enable, 1235// void PPPData::setGraphingOptions(bool enable,
1234 // QColor bg, 1236 // QColor bg,
1235 // QColor text, 1237 // QColor text,
1236 // QColor in, 1238 // QColor in,
1237 // QColor out) 1239 // QColor out)
1238// { 1240// {
1239// if(config) { 1241// if(config) {
1240// config->setGroup(GRAPH_GRP); 1242// config->setGroup(GRAPH_GRP);
1241// config->writeEntry(GENABLED, enable); 1243// config->writeEntry(GENABLED, enable);
1242// // config->writeEntry(GCOLOR_BG, bg); 1244// // config->writeEntry(GCOLOR_BG, bg);
1243// // config->writeEntry(GCOLOR_TEXT, text); 1245// // config->writeEntry(GCOLOR_TEXT, text);
1244// // config->writeEntry(GCOLOR_IN, in); 1246// // config->writeEntry(GCOLOR_IN, in);
1245// // config->writeEntry(GCOLOR_OUT, out); 1247// // config->writeEntry(GCOLOR_OUT, out);
1246// } 1248// }
1247// } 1249// }
1248 1250
1249// void PPPData::graphingOptions(bool &enable, 1251// void PPPData::graphingOptions(bool &enable,
1250 // QColor &bg, 1252 // QColor &bg,
1251 // QColor &text, 1253 // QColor &text,
1252 // QColor &in, 1254 // QColor &in,
1253 // QColor &out) 1255 // QColor &out)
1254// { 1256// {
1255// QColor c; 1257// QColor c;
1256 1258
1257// if(config) { 1259// if(config) {
1258// config->setGroup(GRAPH_GRP); 1260// config->setGroup(GRAPH_GRP);
1259// enable = config->readBoolEntry(GENABLED, true); 1261// enable = config->readBoolEntry(GENABLED, true);
1260// bg = Qt::white; 1262// bg = Qt::white;
1261// //bg = config->readColorEntry(GCOLOR_BG, &c); 1263// //bg = config->readColorEntry(GCOLOR_BG, &c);
1262// text = Qt::black; 1264// text = Qt::black;
1263// //text = config->readColorEntry(GCOLOR_TEXT, &c); 1265// //text = config->readColorEntry(GCOLOR_TEXT, &c);
1264// in = Qt::blue; 1266// in = Qt::blue;
1265// //in = config->readColorEntry(GCOLOR_IN, &c); 1267// //in = config->readColorEntry(GCOLOR_IN, &c);
1266// out = Qt::red; 1268// out = Qt::red;
1267// //out = config->readColorEntry(GCOLOR_OUT, &c); 1269// //out = config->readColorEntry(GCOLOR_OUT, &c);
1268// } 1270// }
1269// } 1271// }
1270 1272
1271 1273
1272// bool PPPData::graphingEnabled() { 1274// bool PPPData::graphingEnabled() {
1273// return (bool) readNumConfig(GRAPH_GRP, GENABLED, true); 1275// return (bool) readNumConfig(GRAPH_GRP, GENABLED, true);
1274// } 1276// }
1275 1277
1276 1278
1277 1279
1278// 1280//
1279//functions to change/set the child pppd process info 1281//functions to change/set the child pppd process info
1280// 1282//
1281bool PPPData::pppdRunning() const { 1283bool PPPData::pppdRunning() const {
1282 return pppdisrunning; 1284 return pppdisrunning;
1283} 1285}
1284 1286
1285void PPPData::setpppdRunning(bool set) { 1287void PPPData::setpppdRunning(bool set) {
1286 pppdisrunning = set; 1288 pppdisrunning = set;
1287} 1289}
1288 1290
1289int PPPData::pppdError() const { 1291int PPPData::pppdError() const {
1290 return pppderror; 1292 return pppderror;
1291} 1293}
1292 1294
1293void PPPData::setpppdError(int err) { 1295void PPPData::setpppdError(int err) {
1294 pppderror = err; 1296 pppderror = err;
1295} 1297}
1296 1298
1297QString PPPData::modemGroup() 1299QString PPPData::modemGroup()
1298{ 1300{
1299 if (_modemName.isEmpty()) 1301 if (_modemName.isEmpty())
1300 _modemName = deviceList[0]; 1302 _modemName = deviceList[0];
1301 return _modemName; 1303 return _modemName;
1302} 1304}
1303 1305
1304 1306
1305QMap<QString,QString> PPPData::getConfiguredInterfaces() 1307QMap<QString,QString> PPPData::getConfiguredInterfaces()
1306{ 1308{
1307 QMap<QString,QString> ifaces; 1309 QMap<QString,QString> ifaces;
1308 Config config = PPPData::config(); 1310 Config config = PPPData::config();
1309 config.setGroup(ACCLIST_GRP); 1311 config.setGroup(ACCLIST_GRP);
1310 int count = config.readNumEntry( ACCOUNTS_COUNT, -1 ); 1312 int count = config.readNumEntry( ACCOUNTS_COUNT, -1 );
1311 QString accGrp, dev, acc; 1313 QString accGrp, dev, acc;
1312 for (int i = 0; i < count; i++){ 1314 for (int i = 0; i < count; i++){
1313 accGrp = QString("%1_%1").arg(ACCLIST_GRP).arg(i); 1315 accGrp = QString("%1_%1").arg(ACCLIST_GRP).arg(i);
1314 config.setGroup(accGrp); 1316 config.setGroup(accGrp);
1315 dev = config.readEntry( ACOUNTS_DEV, "error" ); 1317 dev = config.readEntry( ACOUNTS_DEV, "error" );
1316 acc = config.readEntry( ACOUNTS_ACC, "error" ); 1318 acc = config.readEntry( ACOUNTS_ACC, "error" );
1317 ifaces.insert( dev, acc ); 1319 ifaces.insert( dev, acc );
1318 } 1320 }
1319 1321
1320 return ifaces; 1322 return ifaces;
1321} 1323}
1322 1324
1323void PPPData::setConfiguredInterfaces( QMap<QString,QString> ifaces ) 1325void PPPData::setConfiguredInterfaces( QMap<QString,QString> ifaces )
1324{ 1326{
1325 QMap<QString,QString>::Iterator it; 1327 QMap<QString,QString>::Iterator it;
1326 int i = 0; 1328 int i = 0;
1327 Config cfg = config(); 1329 Config cfg = config();
1328 for( it = ifaces.begin(); it != ifaces.end(); ++it ){ 1330 for( it = ifaces.begin(); it != ifaces.end(); ++it ){
1329 cfg.setGroup(QString("%1_%1").arg(ACCLIST_GRP).arg(i++)); 1331 cfg.setGroup(QString("%1_%1").arg(ACCLIST_GRP).arg(i++));
1330 cfg.writeEntry( ACOUNTS_DEV, it.key() ); 1332 cfg.writeEntry( ACOUNTS_DEV, it.key() );
1331 cfg.writeEntry( ACOUNTS_ACC, it.data() ); 1333 cfg.writeEntry( ACOUNTS_ACC, it.data() );
1332 odebug << "I " << i << "" << oendl; 1334 odebug << "I " << i << "" << oendl;
1333 } 1335 }
1334 cfg.setGroup( ACCLIST_GRP ); 1336 cfg.setGroup( ACCLIST_GRP );
1335 odebug << "saved " << i << " account settings" << oendl; 1337 odebug << "saved " << i << " account settings" << oendl;
1336 cfg.writeEntry( ACCOUNTS_COUNT, i ); 1338 cfg.writeEntry( ACCOUNTS_COUNT, i );
1337 1339
1338} 1340}
1339 1341
1340/** 1342/**
1341 * pppd's getword() function knows about escape characters. 1343 * pppd's getword() function knows about escape characters.
1342 * If we write the username and password to the secrets file 1344 * If we write the username and password to the secrets file
1343 * we'll therefore have to escape back slashes. 1345 * we'll therefore have to escape back slashes.
1344 */ 1346 */
1345QString PPPData::encodeWord(const QString &s) { 1347QString PPPData::encodeWord(const QString &s) {
1346 QString r = s; 1348 QString r = s;
1347 r.replace(QRegExp("\\"), "\\\\"); 1349 r.replace(QRegExp("\\"), "\\\\");
1348 return r; 1350 return r;
1349} 1351}
1350 1352
1351QStringList PPPData::getDevicesList() 1353QStringList PPPData::getDevicesList()
1352{ 1354{
1353 Config cfg("NetworkSetupPPP"); 1355 Config cfg("NetworkSetupPPP");
1354 cfg.setGroup("Devices_General"); 1356 cfg.setGroup("Devices_General");
1355 return cfg.readListEntry(DEVICES_LIST,DEVICES_LIST_SEP); 1357 return cfg.readListEntry(DEVICES_LIST,DEVICES_LIST_SEP);
1356} 1358}
1357 1359
1358QStringList PPPData::getAccountList() 1360QStringList PPPData::getAccountList()
1359{ 1361{
1360 QStringList list; 1362 QStringList list;
1361 QString save_cgroup; 1363 QString save_cgroup;
1362 save_cgroup = cgroup; 1364 save_cgroup = cgroup;
1363 for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) { 1365 for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) {
1364 cgroup = *it; 1366 cgroup = *it;
1365 list << accname(); 1367 list << accname();
1366 } 1368 }
1367 cgroup = save_cgroup; 1369 cgroup = save_cgroup;
1368 return list; 1370 return list;
1369}; 1371};
1370 1372
1371 1373
1372const QString PPPData::devname() 1374const QString PPPData::devname()
1373{ 1375{
1374 QString tmp = readConfig(modemGroup(), MODEMNAME_KEY ); 1376 QString tmp = readConfig(modemGroup(), MODEMNAME_KEY );
1375 odebug << "PPPData::devname() of " << modemGroup().latin1() << " is " << tmp.latin1() << "" << oendl; 1377 odebug << "PPPData::devname() of " << modemGroup().latin1() << " is " << tmp.latin1() << "" << oendl;
1376 return tmp; 1378 return tmp;
1377} 1379}
1378 1380
1379void PPPData::setDevname(const QString &n) { 1381void PPPData::setDevname(const QString &n) {
1380 // if(!cgroup.isNull()) { 1382 // if(!cgroup.isNull()) {
1381// // are we manipulating the default account's name ? then change it, too. 1383// // are we manipulating the default account's name ? then change it, too.
1382// bool def = accname() == defaultAccount(); 1384// bool def = accname() == defaultAccount();
1383// writeConfig(cgroup, NAME_KEY, n); 1385// writeConfig(cgroup, NAME_KEY, n);
1384// if (def) 1386// if (def)
1385// setDefaultAccount(n); 1387// setDefaultAccount(n);
1386// } 1388// }
1387 writeConfig(modemGroup(), MODEMNAME_KEY, n ); 1389 writeConfig(modemGroup(), MODEMNAME_KEY, n );
1388} 1390}
1389 1391
1390 1392
1391bool PPPData::setDevice(const QString &dev ) 1393bool PPPData::setDevice(const QString &dev )
1392{ 1394{
1393 odebug << "setting device to >" << dev.latin1() << "<" << oendl; 1395 odebug << "setting device to >" << dev.latin1() << "<" << oendl;
1394 QString save_mName = _modemName; 1396 QString save_mName = _modemName;
1395 for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) { 1397 for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) {
1396 _modemName = *it; 1398 _modemName = *it;
1397 odebug << "PPPData::setDevice " << _modemName.latin1() << " is named " << devname().latin1() << "" << oendl; 1399 odebug << "PPPData::setDevice " << _modemName.latin1() << " is named " << devname().latin1() << "" << oendl;
1398 odebug << "iterator " << (*it).latin1() << "" << oendl; 1400 odebug << "iterator " << (*it).latin1() << "" << oendl;
1399 if(devname() == dev) { 1401 if(devname() == dev) {
1400 odebug << "SUCCESS" << oendl; 1402 odebug << "SUCCESS" << oendl;
1401 return true; 1403 return true;
1402 } 1404 }
1403 1405
1404 } 1406 }
1405 _modemName = save_mName; 1407 _modemName = save_mName;
1406 odebug << "FAILURE" << oendl; 1408 odebug << "FAILURE" << oendl;
1407 return false; 1409 return false;
1408} 1410}
1409 1411
1410bool PPPData::deleteDevice() 1412bool PPPData::deleteDevice()
1411{ 1413{
1412 // FIXME: check if this account exists in a config... 1414 // FIXME: check if this account exists in a config...
1413 Config cfg = PPPData::config(); 1415 Config cfg = PPPData::config();
1414 cfg.setGroup(modemGroup()); 1416 cfg.setGroup(modemGroup());
1415 cfg.clearGroup(); 1417 cfg.clearGroup();
1416 deviceList.remove(modemGroup()); 1418 deviceList.remove(modemGroup());
1417 1419
1418 QString key; 1420 QString key;
1419 QStringList keys; 1421 QStringList keys;
1420 for( QMap<QString,QString>::Iterator it = stringEntries.begin(); 1422 for( QMap<QString,QString>::Iterator it = stringEntries.begin();
1421 it != stringEntries.end(); ++it ){ 1423 it != stringEntries.end(); ++it ){
1422 QString val = it.data(); 1424 QString val = it.data();
1423 key = it.key(); 1425 key = it.key();
1424 keys = QStringList::split( "SEPARATOR", key ); 1426 keys = QStringList::split( "SEPARATOR", key );
1425 if(keys[0]==modemGroup()){ 1427 if(keys[0]==modemGroup()){
1426 stringEntries.remove( it ); 1428 stringEntries.remove( it );
1427 odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.latin1() << "<" << oendl; 1429 odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.latin1() << "<" << oendl;
1428 } 1430 }
1429 } 1431 }
1430 for( QMap<QString,int>::Iterator it = intEntries.begin(); 1432 for( QMap<QString,int>::Iterator it = intEntries.begin();
1431 it != intEntries.end(); ++it ){ 1433 it != intEntries.end(); ++it ){
1432 int val = it.data(); 1434 int val = it.data();
1433 key = it.key(); 1435 key = it.key();
1434 keys = QStringList::split( "SEPARATOR", key ); 1436 keys = QStringList::split( "SEPARATOR", key );
1435 if(keys[0]==modemGroup()){ 1437 if(keys[0]==modemGroup()){
1436 intEntries.remove( it ); 1438 intEntries.remove( it );
1437 odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val << "<" << oendl; 1439 odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val << "<" << oendl;
1438 } 1440 }
1439 } 1441 }
1440 for( QMap<QString,QStringList>::Iterator it = listEntries.begin(); 1442 for( QMap<QString,QStringList>::Iterator it = listEntries.begin();
1441 it != listEntries.end(); ++it ){ 1443 it != listEntries.end(); ++it ){
1442 QStringList val = it.data(); 1444 QStringList val = it.data();
1443 key = it.key(); 1445 key = it.key();
1444 if(keys[0]==modemGroup()){ 1446 if(keys[0]==modemGroup()){
1445 listEntries.remove( it ); 1447 listEntries.remove( it );
1446 sepEntries.remove( key ); 1448 sepEntries.remove( key );
1447 odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.join("").latin1() << "<" << oendl; 1449 odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.join("").latin1() << "<" << oendl;
1448 } 1450 }
1449 } 1451 }
1450 1452
1451 return true; 1453 return true;
1452 1454
1453} 1455}
1454 1456
1455bool PPPData::deleteDevice(const QString &dev) 1457bool PPPData::deleteDevice(const QString &dev)
1456{ 1458{
1457 if(!setDevice(dev)) 1459 if(!setDevice(dev))
1458 return false; 1460 return false;
1459 1461
1460 return deleteDevice(); 1462 return deleteDevice();
1461} 1463}
1462 1464
1463int PPPData::newdevice() 1465int PPPData::newdevice()
1464{ 1466{
1465 1467
1466 odebug << "PPPData::newdevice highcount " << highcountdev << "" << oendl; 1468 odebug << "PPPData::newdevice highcount " << highcountdev << "" << oendl;
1467 1469
1468 1470
1469 QString tmp; 1471 QString tmp;
1470 tmp.sprintf("%s%i", MODEM_GRP, ++highcountdev); 1472 tmp.sprintf("%s%i", MODEM_GRP, ++highcountdev);
1471 _modemName = QString(tmp); 1473 _modemName = QString(tmp);
1472 deviceList << tmp; 1474 deviceList << tmp;
1473 odebug << "PPPData::newdevice() Group: >" << cgroup.latin1() << "<" << oendl; 1475 odebug << "PPPData::newdevice() Group: >" << cgroup.latin1() << "<" << oendl;
1474 return highcountdev; 1476 return highcountdev;
1475} 1477}
1476 1478
1477int PPPData::copydevice(const QString&) 1479int PPPData::copydevice(const QString&)
1478{ 1480{
1479 return false; 1481 return false;
1480} 1482}
1481 1483
1482 1484
1483QStringList PPPData::getDevicesNamesList() 1485QStringList PPPData::getDevicesNamesList()
1484{ 1486{
1485 QStringList list; 1487 QStringList list;
1486 QString save_mName = _modemName; 1488 QString save_mName = _modemName;
1487 odebug << "PPPData::getDevicesNamesList has " << deviceList.join("---").latin1() << "" << oendl; 1489 odebug << "PPPData::getDevicesNamesList has " << deviceList.join("---").latin1() << "" << oendl;
1488 for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) { 1490 for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) {
1489 _modemName = *it; 1491 _modemName = *it;
1490 odebug << "PPPData::getDevicesNamesList adding " << _modemName.latin1() << " as " << devname().latin1() << "" << oendl; 1492 odebug << "PPPData::getDevicesNamesList adding " << _modemName.latin1() << " as " << devname().latin1() << "" << oendl;
1491 list << devname(); 1493 list << devname();
1492 } 1494 }
1493 _modemName = save_mName; 1495 _modemName = save_mName;
1494 return list; 1496 return list;
1495}; 1497};
diff --git a/noncore/settings/networksettings/ppp/pppmodule.cpp b/noncore/settings/networksettings/ppp/pppmodule.cpp
index 2291e8a..b102a10 100644
--- a/noncore/settings/networksettings/ppp/pppmodule.cpp
+++ b/noncore/settings/networksettings/ppp/pppmodule.cpp
@@ -1,283 +1,285 @@
1 1
2#include "modem.h" 2#include "modem.h"
3#include "pppconfig.h" 3#include "pppconfig.h"
4#include "pppmodule.h" 4#include "pppmodule.h"
5#include "pppdata.h" 5#include "pppdata.h"
6#include "interfaceinformationppp.h" 6#include "interfaceinformationppp.h"
7#include "interfaceppp.h" 7#include "interfaceppp.h"
8 8
9/* OPIE */ 9/* OPIE */
10#include <opie2/odebug.h>
10#include <qpe/config.h> 11#include <qpe/config.h>
11#include <qpe/qpeapplication.h> 12#include <qpe/qpeapplication.h>
13using namespace Opie::Core;
12 14
13/* QT */ 15/* QT */
14 16
15/* STD */ 17/* STD */
16#include <errno.h> 18#include <errno.h>
17#include <signal.h> 19#include <signal.h>
18 20
19// don't polute global namespace 21// don't polute global namespace
20namespace 22namespace
21{ 23{
22 /* 24 /*
23 * If network settings is qutting and we've ppp 25 * If network settings is qutting and we've ppp
24 * devices open we need to save the pid_t the PPData 26 * devices open we need to save the pid_t the PPData
25 * and the interface number 27 * and the interface number
26 */ 28 */
27 struct Connection 29 struct Connection
28 { 30 {
29 pid_t pid; 31 pid_t pid;
30 QString device; 32 QString device;
31 QString name; 33 QString name;
32 }; 34 };
33 class InterfaceKeeper 35 class InterfaceKeeper
34 { 36 {
35 public: 37 public:
36 InterfaceKeeper(); 38 InterfaceKeeper();
37 ~InterfaceKeeper(); 39 ~InterfaceKeeper();
38 40
39 void addInterface( pid_t, const QString& pppDev, const QString& name ); 41 void addInterface( pid_t, const QString& pppDev, const QString& name );
40 QMap<QString, Connection> interfaces()const; // will check if still available 42 QMap<QString, Connection> interfaces()const; // will check if still available
41 private: 43 private:
42 bool isAvailable( pid_t )const; 44 bool isAvailable( pid_t )const;
43 QMap<QString, Connection> m_interfaces; 45 QMap<QString, Connection> m_interfaces;
44 }; 46 };
45} 47}
46 48
47 49
48/** 50/**
49 * Constructor, find all of the possible interfaces 51 * Constructor, find all of the possible interfaces
50 * We also need to restore the state.. it could be that 52 * We also need to restore the state.. it could be that
51 * an interface was up while closing the application 53 * an interface was up while closing the application
52 * we need to be able to shut it down... 54 * we need to be able to shut it down...
53 */ 55 */
54PPPModule::PPPModule() : Module() 56PPPModule::PPPModule() : Module()
55{ 57{
56 InterfaceKeeper inFace; 58 InterfaceKeeper inFace;
57 QMap<QString,Connection> running = inFace.interfaces(); 59 QMap<QString,Connection> running = inFace.interfaces();
58 QStringList handledInterfaceNames; 60 QStringList handledInterfaceNames;
59 61
60 QMap<QString,QString> ifaces = PPPData::getConfiguredInterfaces(); 62 QMap<QString,QString> ifaces = PPPData::getConfiguredInterfaces();
61 QMap<QString,QString>::Iterator it; 63 QMap<QString,QString>::Iterator it;
62 InterfacePPP *iface; 64 InterfacePPP *iface;
63 odebug << "getting interfaces" << oendl; 65 odebug << "getting interfaces" << oendl;
64 for( it = ifaces.begin(); it != ifaces.end(); ++it ) 66 for( it = ifaces.begin(); it != ifaces.end(); ++it )
65 { 67 {
66 odebug << "ifaces " << it.key().latin1() << " " << it.data().latin1() << "" << oendl; 68 odebug << "ifaces " << it.key().latin1() << " " << it.data().latin1() << "" << oendl;
67 iface = new InterfacePPP( 0, it.key() ); 69 iface = new InterfacePPP( 0, it.key() );
68 iface->setHardwareName( it.data() ); 70 iface->setHardwareName( it.data() );
69 list.append( (Interface*)iface ); 71 list.append( (Interface*)iface );
70 72
71 // check if (*it) is one of the running ifaces 73 // check if (*it) is one of the running ifaces
72 if ( running.contains( it.data() ) ) 74 if ( running.contains( it.data() ) )
73 { 75 {
74 odebug << "iface is running " << it.key().latin1() << "" << oendl; 76 odebug << "iface is running " << it.key().latin1() << "" << oendl;
75 handledInterfaceNames << running[it.data()].device; 77 handledInterfaceNames << running[it.data()].device;
76 iface->setStatus( true ); 78 iface->setStatus( true );
77 iface->setPPPDpid( running[it.data()].pid ); 79 iface->setPPPDpid( running[it.data()].pid );
78 iface->modem()->setPPPDevice( running[it.data()].device ); 80 iface->modem()->setPPPDevice( running[it.data()].device );
79 iface->refresh(); 81 iface->refresh();
80 } 82 }
81 } 83 }
82 84
83 setHandledInterfaceNames( handledInterfaceNames ); 85 setHandledInterfaceNames( handledInterfaceNames );
84} 86}
85 87
86/** 88/**
87 * Delete any interfaces that we own. 89 * Delete any interfaces that we own.
88 */ 90 */
89PPPModule::~PPPModule() 91PPPModule::~PPPModule()
90{ 92{
91 odebug << "PPPModule::~PPPModule() " << oendl; 93 odebug << "PPPModule::~PPPModule() " << oendl;
92 QMap<QString,QString> ifaces; 94 QMap<QString,QString> ifaces;
93 InterfaceKeeper keeper; 95 InterfaceKeeper keeper;
94 Interface *i; 96 Interface *i;
95 for ( i=list.first(); i != 0; i=list.next() ) 97 for ( i=list.first(); i != 0; i=list.next() )
96 { 98 {
97 /* if online save the state */ 99 /* if online save the state */
98 if ( i->getStatus() ) 100 if ( i->getStatus() )
99 { 101 {
100 odebug << "Iface " << i->getHardwareName().latin1() << " is still up" << oendl; 102 odebug << "Iface " << i->getHardwareName().latin1() << " is still up" << oendl;
101 InterfacePPP* ppp = static_cast<InterfacePPP*>(i); 103 InterfacePPP* ppp = static_cast<InterfacePPP*>(i);
102 keeper.addInterface( ppp->pppPID(), ppp->pppDev(), ppp->getHardwareName() ); 104 keeper.addInterface( ppp->pppPID(), ppp->pppDev(), ppp->getHardwareName() );
103 } 105 }
104 ifaces.insert( i->getInterfaceName(), i->getHardwareName() ); 106 ifaces.insert( i->getInterfaceName(), i->getHardwareName() );
105 delete i; 107 delete i;
106 } 108 }
107 PPPData::setConfiguredInterfaces( ifaces ); 109 PPPData::setConfiguredInterfaces( ifaces );
108} 110}
109 111
110/** 112/**
111 * Change the current profile 113 * Change the current profile
112 */ 114 */
113void PPPModule::setProfile(const QString &newProfile) 115void PPPModule::setProfile(const QString &newProfile)
114{ 116{
115 profile = newProfile; 117 profile = newProfile;
116} 118}
117 119
118/** 120/**
119 * get the icon name for this device. 121 * get the icon name for this device.
120 * @param Interface* can be used in determining the icon. 122 * @param Interface* can be used in determining the icon.
121 * @return QString the icon name (minus .png, .gif etc) 123 * @return QString the icon name (minus .png, .gif etc)
122 */ 124 */
123QString PPPModule::getPixmapName(Interface* ) 125QString PPPModule::getPixmapName(Interface* )
124{ 126{
125 return "ppp"; 127 return "ppp";
126} 128}
127 129
128/** 130/**
129 * Check to see if the interface i is owned by this module. 131 * Check to see if the interface i is owned by this module.
130 * @param Interface* interface to check against 132 * @param Interface* interface to check against
131 * @return bool true if i is owned by this module, false otherwise. 133 * @return bool true if i is owned by this module, false otherwise.
132 */ 134 */
133bool PPPModule::isOwner(Interface *i) 135bool PPPModule::isOwner(Interface *i)
134{ 136{
135 return list.find( i ) != -1; 137 return list.find( i ) != -1;
136} 138}
137 139
138/** 140/**
139 * Create, and return the WLANConfigure Module 141 * Create, and return the WLANConfigure Module
140 * @return QWidget* pointer to this modules configure. 142 * @return QWidget* pointer to this modules configure.
141 */ 143 */
142QWidget *PPPModule::configure(Interface *i) 144QWidget *PPPModule::configure(Interface *i)
143{ 145{
144 odebug << "return ModemWidget" << oendl; 146 odebug << "return ModemWidget" << oendl;
145 PPPConfigWidget *pppconfig = new PPPConfigWidget( (InterfacePPP*)i, 147 PPPConfigWidget *pppconfig = new PPPConfigWidget( (InterfacePPP*)i,
146 0, "PPPConfig", false, 148 0, "PPPConfig", false,
147 (Qt::WDestructiveClose | Qt::WStyle_ContextHelp)); 149 (Qt::WDestructiveClose | Qt::WStyle_ContextHelp));
148 return pppconfig; 150 return pppconfig;
149} 151}
150 152
151/** 153/**
152 * Create, and return the Information Module 154 * Create, and return the Information Module
153 * @return QWidget* pointer to this modules info. 155 * @return QWidget* pointer to this modules info.
154 */ 156 */
155QWidget *PPPModule::information(Interface *i) 157QWidget *PPPModule::information(Interface *i)
156{ 158{
157 // We don't have any advanced pppd information widget yet :-D 159 // We don't have any advanced pppd information widget yet :-D
158 // TODO ^ 160 // TODO ^
159 161
160 return new InterfaceInformationPPP( 0, "InterfaceInformationPPP", i ); 162 return new InterfaceInformationPPP( 0, "InterfaceInformationPPP", i );
161} 163}
162 164
163/** 165/**
164 * Get all active (up or down) interfaces 166 * Get all active (up or down) interfaces
165 * @return QList<Interface> A list of interfaces that exsist that havn't 167 * @return QList<Interface> A list of interfaces that exsist that havn't
166 * been called by isOwner() 168 * been called by isOwner()
167 */ 169 */
168QList<Interface> PPPModule::getInterfaces() 170QList<Interface> PPPModule::getInterfaces()
169{ 171{
170 // List all of the files in the peer directory 172 // List all of the files in the peer directory
171 odebug << "PPPModule::getInterfaces" << oendl; 173 odebug << "PPPModule::getInterfaces" << oendl;
172 return list; 174 return list;
173} 175}
174 176
175/** 177/**
176 * Attempt to add a new interface as defined by name 178 * Attempt to add a new interface as defined by name
177 * @param name the name of the type of interface that should be created given 179 * @param name the name of the type of interface that should be created given
178 * by possibleNewInterfaces(); 180 * by possibleNewInterfaces();
179 * @return Interface* NULL if it was unable to be created. 181 * @return Interface* NULL if it was unable to be created.
180 */ 182 */
181Interface *PPPModule::addNewInterface(const QString &newInterface) 183Interface *PPPModule::addNewInterface(const QString &newInterface)
182{ 184{
183 185
184 InterfacePPP *ifaceppp; 186 InterfacePPP *ifaceppp;
185 Interface *iface; 187 Interface *iface;
186 ifaceppp = new InterfacePPP(); 188 ifaceppp = new InterfacePPP();
187 PPPConfigWidget imp(ifaceppp, 0, "PPPConfigImp", true); 189 PPPConfigWidget imp(ifaceppp, 0, "PPPConfigImp", true);
188 190
189 if( QPEApplication::execDialog( &imp ) == QDialog::Accepted ) 191 if( QPEApplication::execDialog( &imp ) == QDialog::Accepted )
190 { 192 {
191 iface = (InterfacePPP*) ifaceppp; 193 iface = (InterfacePPP*) ifaceppp;
192 iface->setModuleOwner( this ); 194 iface->setModuleOwner( this );
193 list.append( iface ); 195 list.append( iface );
194 return iface; 196 return iface;
195 } 197 }
196 else 198 else
197 { 199 {
198 delete ifaceppp; 200 delete ifaceppp;
199 iface = NULL; 201 iface = NULL;
200 } 202 }
201 return iface; 203 return iface;
202} 204}
203 205
204/** 206/**
205 * Attempts to remove the interface, doesn't delete i 207 * Attempts to remove the interface, doesn't delete i
206 * @return bool true if successful, false otherwise. 208 * @return bool true if successful, false otherwise.
207 */ 209 */
208bool PPPModule::remove(Interface *i) 210bool PPPModule::remove(Interface *i)
209{ 211{
210 return list.remove(i); 212 return list.remove(i);
211} 213}
212 214
213void PPPModule::possibleNewInterfaces(QMap<QString, QString> &newIfaces) 215void PPPModule::possibleNewInterfaces(QMap<QString, QString> &newIfaces)
214{ 216{
215 newIfaces.insert(QObject::tr("PPP") , 217 newIfaces.insert(QObject::tr("PPP") ,
216 QObject::tr("generic ppp device")); 218 QObject::tr("generic ppp device"));
217} 219}
218 220
219 221
220 222
221namespace 223namespace
222{ 224{
223 InterfaceKeeper::InterfaceKeeper( ) 225 InterfaceKeeper::InterfaceKeeper( )
224 {} 226 {}
225 InterfaceKeeper::~InterfaceKeeper() 227 InterfaceKeeper::~InterfaceKeeper()
226 { 228 {
227 Config cfg("ppp_plugin_keeper"); 229 Config cfg("ppp_plugin_keeper");
228 QStringList lst = cfg.groupList(); 230 QStringList lst = cfg.groupList();
229 for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) 231 for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it )
230 { 232 {
231 Connection con; 233 Connection con;
232 cfg.setGroup( (*it) ); 234 cfg.setGroup( (*it) );
233 cfg.clearGroup(); 235 cfg.clearGroup();
234 } 236 }
235 237
236 for (QMap<QString, Connection>::Iterator it = m_interfaces.begin(); it != m_interfaces.end(); ++it ) 238 for (QMap<QString, Connection>::Iterator it = m_interfaces.begin(); it != m_interfaces.end(); ++it )
237 { 239 {
238 Connection con = it.data(); 240 Connection con = it.data();
239 cfg.setGroup( con.name ); 241 cfg.setGroup( con.name );
240 cfg.writeEntry( "pid", con.pid ); 242 cfg.writeEntry( "pid", con.pid );
241 cfg.writeEntry( "device", con.device ); 243 cfg.writeEntry( "device", con.device );
242 } 244 }
243 } 245 }
244 void InterfaceKeeper::addInterface(pid_t pid, const QString& dev, const QString& name ) 246 void InterfaceKeeper::addInterface(pid_t pid, const QString& dev, const QString& name )
245 { 247 {
246 Connection con; 248 Connection con;
247 con.pid = pid; 249 con.pid = pid;
248 con.device = dev; 250 con.device = dev;
249 con.name = name; 251 con.name = name;
250 m_interfaces.insert( name, con ); 252 m_interfaces.insert( name, con );
251 } 253 }
252 QMap<QString, Connection> InterfaceKeeper::interfaces()const 254 QMap<QString, Connection> InterfaceKeeper::interfaces()const
253 { 255 {
254 Config cfg("ppp_plugin_keeper"); 256 Config cfg("ppp_plugin_keeper");
255 QMap<QString, Connection> ifaces; 257 QMap<QString, Connection> ifaces;
256 QStringList lst = cfg.groupList(); 258 QStringList lst = cfg.groupList();
257 for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) 259 for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it )
258 { 260 {
259 Connection con; 261 Connection con;
260 cfg.setGroup( (*it) ); 262 cfg.setGroup( (*it) );
261 con.name = (*it); 263 con.name = (*it);
262 con.pid = cfg.readNumEntry("pid"); 264 con.pid = cfg.readNumEntry("pid");
263 con.device = cfg.readEntry("device"); 265 con.device = cfg.readEntry("device");
264 odebug << " " << con.name.latin1() << " " << con.device.latin1() << " " << con.pid << "" << oendl; 266 odebug << " " << con.name.latin1() << " " << con.device.latin1() << " " << con.pid << "" << oendl;
265 267
266 if ( con.pid != -1 && isAvailable( con.pid ) ) 268 if ( con.pid != -1 && isAvailable( con.pid ) )
267 ifaces.insert( con.name, con ); 269 ifaces.insert( con.name, con );
268 } 270 }
269 return ifaces; 271 return ifaces;
270 } 272 }
271 bool InterfaceKeeper::isAvailable( pid_t p)const 273 bool InterfaceKeeper::isAvailable( pid_t p)const
272 { 274 {
273 if (::kill(p, 0 ) == 0 || errno != ESRCH ) 275 if (::kill(p, 0 ) == 0 || errno != ESRCH )
274 { 276 {
275 odebug << "isAvailable " << p << "" << oendl; 277 odebug << "isAvailable " << p << "" << oendl;
276 return true; 278 return true;
277 } 279 }
278 280
279 odebug << "notAvailable " << p << "" << oendl; 281 odebug << "notAvailable " << p << "" << oendl;
280 return false; 282 return false;
281 } 283 }
282 284
283} 285}
diff --git a/noncore/settings/networksettings/wlan/config.in b/noncore/settings/networksettings/wlan/config.in
index d4661cb..233764e 100644
--- a/noncore/settings/networksettings/wlan/config.in
+++ b/noncore/settings/networksettings/wlan/config.in
@@ -1,6 +1,6 @@
1 config WLAN 1 config WLAN
2 boolean "opie-networksettingsplugin-wlan (wireless LAN module)" 2 boolean "opie-networksettingsplugin-wlan (wireless LAN module)"
3 default "n" if NETWORKSETUP 3 default "y"
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2UI && NETWORKSETUP && NETWORKSETUP-CORE && INTERFACES && LIBOPIE2NET 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2UI && NETWORKSETUP && NETWORKSETUP-CORE && INTERFACES && LIBOPIE2NET
5 #comment "opie-networksettingsplugin-wlan needs libopie2ui, libopie2net and networksetup" 5 #comment "opie-networksettingsplugin-wlan needs libopie2ui, libopie2net and networksetup"
6 #depends !( LIBOPIE2NET && NETWORKSETUP) \ No newline at end of file 6 #depends !( LIBOPIE2NET && NETWORKSETUP)
diff --git a/noncore/settings/networksettings/wlan/infoimp.cpp b/noncore/settings/networksettings/wlan/infoimp.cpp
index c558f5e..273bed8 100644
--- a/noncore/settings/networksettings/wlan/infoimp.cpp
+++ b/noncore/settings/networksettings/wlan/infoimp.cpp
@@ -1,56 +1,61 @@
1#include "infoimp.h" 1#include "infoimp.h"
2#include "wextensions.h" 2#include "wextensions.h"
3 3
4/* OPIE */
5#include <opie2/odebug.h>
6using namespace Opie::Core;
7
8/* QT */
4#include <qtimer.h> 9#include <qtimer.h>
5#include <qprogressbar.h> 10#include <qprogressbar.h>
6#include <qlabel.h> 11#include <qlabel.h>
7 12
8/** 13/**
9 * Constructor. If wireless extensions are enabled on device name then 14 * Constructor. If wireless extensions are enabled on device name then
10 * start a timer that every second will update the information. 15 * start a timer that every second will update the information.
11 */ 16 */
12WlanInfoImp::WlanInfoImp( QWidget* parent, const char* name, WFlags fl): WlanInfo(parent, name, fl){ 17WlanInfoImp::WlanInfoImp( QWidget* parent, const char* name, WFlags fl): WlanInfo(parent, name, fl){
13 WExtensions *wExtensions = new WExtensions(name); 18 WExtensions *wExtensions = new WExtensions(name);
14 if(!wExtensions->doesHaveWirelessExtensions()){ 19 if(!wExtensions->doesHaveWirelessExtensions()){
15 delete wExtensions; 20 delete wExtensions;
16 odebug << "WlanInfoImp::No wireless extension" << oendl; 21 odebug << "WlanInfoImp::No wireless extension" << oendl;
17 return; 22 return;
18 } 23 }
19 delete wExtensions; 24 delete wExtensions;
20 timer = new QTimer( this ); 25 timer = new QTimer( this );
21 connect( timer, SIGNAL(timeout()), this, SLOT(update())); 26 connect( timer, SIGNAL(timeout()), this, SLOT(update()));
22 timer->start( 1000, false ); 27 timer->start( 1000, false );
23} 28}
24 29
25/** 30/**
26 * Updates the information about the wireless device. 31 * Updates the information about the wireless device.
27 */ 32 */
28void WlanInfoImp::update(){ 33void WlanInfoImp::update(){
29 WExtensions *wExtensions = new WExtensions(this->name()); 34 WExtensions *wExtensions = new WExtensions(this->name());
30 if(!wExtensions->doesHaveWirelessExtensions()){ 35 if(!wExtensions->doesHaveWirelessExtensions()){
31 odebug << "No extension" << oendl; 36 odebug << "No extension" << oendl;
32 delete wExtensions; 37 delete wExtensions;
33 timer->stop(); 38 timer->stop();
34 return; 39 return;
35 } 40 }
36 essidLabel->setText(wExtensions->essid()); 41 essidLabel->setText(wExtensions->essid());
37 apLabel->setText(wExtensions->ap()); 42 apLabel->setText(wExtensions->ap());
38 stationLabel->setText(wExtensions->station()); 43 stationLabel->setText(wExtensions->station());
39 modeLabel->setText(wExtensions->mode()); 44 modeLabel->setText(wExtensions->mode());
40 channelLabel->setText(QString("%1").arg(wExtensions->channel())); 45 channelLabel->setText(QString("%1").arg(wExtensions->channel()));
41 int signal = 0; 46 int signal = 0;
42 int noise = 0; 47 int noise = 0;
43 int quality = 0; 48 int quality = 0;
44 wExtensions->stats(signal, noise, quality); 49 wExtensions->stats(signal, noise, quality);
45 if(signalProgressBar->progress() != signal) 50 if(signalProgressBar->progress() != signal)
46 signalProgressBar->setProgress(signal); 51 signalProgressBar->setProgress(signal);
47 if(noiseProgressBar->progress() != noise) 52 if(noiseProgressBar->progress() != noise)
48 noiseProgressBar->setProgress(noise); 53 noiseProgressBar->setProgress(noise);
49 if(qualityProgressBar->progress() != quality) 54 if(qualityProgressBar->progress() != quality)
50 qualityProgressBar->setProgress(quality); 55 qualityProgressBar->setProgress(quality);
51 rateLabel->setText(QString("%1 Mb/s").arg(wExtensions->rate())); 56 rateLabel->setText(QString("%1 Mb/s").arg(wExtensions->rate()));
52 delete wExtensions; 57 delete wExtensions;
53} 58}
54 59
55// infoimp.cpp 60// infoimp.cpp
56 61
diff --git a/noncore/settings/networksettings/wlan/wextensions.cpp b/noncore/settings/networksettings/wlan/wextensions.cpp
index 9c64323..fe21f02 100644
--- a/noncore/settings/networksettings/wlan/wextensions.cpp
+++ b/noncore/settings/networksettings/wlan/wextensions.cpp
@@ -1,200 +1,207 @@
1#include "wextensions.h" 1#include "wextensions.h"
2 2
3/* OPIE */
4#include <opie2/odebug.h>
5using namespace Opie::Core;
6
7/* QT */
3#include <qfile.h> 8#include <qfile.h>
4#include <qtextstream.h> 9#include <qtextstream.h>
5 10
11/* STD */
6#include <arpa/inet.h> 12#include <arpa/inet.h>
7#include <sys/socket.h> 13#include <sys/socket.h>
8#include <sys/ioctl.h> 14#include <sys/ioctl.h>
9
10#include <math.h> 15#include <math.h>
11 16
12#define PROCNETWIRELESS "/proc/net/wireless" 17#define PROCNETWIRELESS "/proc/net/wireless"
13#define IW_LOWER 0 18#define IW_LOWER 0
14#define IW_UPPER 256 19#define IW_UPPER 256
15 20
21#warning This is duplicated code. Use libopienet2!
22
16/** 23/**
17 * Constructor. Sets hasWirelessExtensions 24 * Constructor. Sets hasWirelessExtensions
18 */ 25 */
19WExtensions::WExtensions(QString interfaceName): hasWirelessExtensions(false), interface(interfaceName) { 26WExtensions::WExtensions(QString interfaceName): hasWirelessExtensions(false), interface(interfaceName) {
20 fd = socket( AF_INET, SOCK_DGRAM, 0 ); 27 fd = socket( AF_INET, SOCK_DGRAM, 0 );
21 if(fd == -1) 28 if(fd == -1)
22 return; 29 return;
23 30
24 const char* buffer[200]; 31 const char* buffer[200];
25 memset( &iwr, 0, sizeof( iwr ) ); 32 memset( &iwr, 0, sizeof( iwr ) );
26 iwr.u.essid.pointer = (caddr_t) buffer; 33 iwr.u.essid.pointer = (caddr_t) buffer;
27 iwr.u.essid.length = IW_ESSID_MAX_SIZE; 34 iwr.u.essid.length = IW_ESSID_MAX_SIZE;
28 iwr.u.essid.flags = 0; 35 iwr.u.essid.flags = 0;
29 36
30 // check if it is an IEEE 802.11 standard conform 37 // check if it is an IEEE 802.11 standard conform
31 // wireless device by sending SIOCGIWESSID 38 // wireless device by sending SIOCGIWESSID
32 // which also gives back the Extended Service Set ID 39 // which also gives back the Extended Service Set ID
33 // (see IEEE 802.11 for more information) 40 // (see IEEE 802.11 for more information)
34 41
35 const char* iname = interface.latin1(); 42 const char* iname = interface.latin1();
36 strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname ); 43 strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname );
37 if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr ) ) 44 if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr ) )
38 hasWirelessExtensions = true; 45 hasWirelessExtensions = true;
39} 46}
40 47
41/** 48/**
42 * @return QString the station name of the access point. 49 * @return QString the station name of the access point.
43 */ 50 */
44QString WExtensions::station(){ 51QString WExtensions::station(){
45 if(!hasWirelessExtensions) 52 if(!hasWirelessExtensions)
46 return QString(); 53 return QString();
47 const char* buffer[200]; 54 const char* buffer[200];
48 iwr.u.data.pointer = (caddr_t) buffer; 55 iwr.u.data.pointer = (caddr_t) buffer;
49 iwr.u.data.length = IW_ESSID_MAX_SIZE; 56 iwr.u.data.length = IW_ESSID_MAX_SIZE;
50 iwr.u.data.flags = 0; 57 iwr.u.data.flags = 0;
51 if ( 0 == ioctl( fd, SIOCGIWNICKN, &iwr )){ 58 if ( 0 == ioctl( fd, SIOCGIWNICKN, &iwr )){
52 iwr.u.data.pointer[(unsigned int) iwr.u.data.length-1] = '\0'; 59 iwr.u.data.pointer[(unsigned int) iwr.u.data.length-1] = '\0';
53 return QString(iwr.u.data.pointer); 60 return QString(iwr.u.data.pointer);
54 } 61 }
55 return QString(); 62 return QString();
56} 63}
57 64
58/** 65/**
59 * @return QString the essid of the host 802.11 access point. 66 * @return QString the essid of the host 802.11 access point.
60 */ 67 */
61QString WExtensions::essid(){ 68QString WExtensions::essid(){
62 if(!hasWirelessExtensions) 69 if(!hasWirelessExtensions)
63 return QString(); 70 return QString();
64 if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr )){ 71 if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr )){
65 iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length] = '\0'; 72 iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length] = '\0';
66 return QString(iwr.u.essid.pointer); 73 return QString(iwr.u.essid.pointer);
67 } 74 }
68 return QString(); 75 return QString();
69} 76}
70 77
71/** 78/**
72 * @return QString the mode of interface 79 * @return QString the mode of interface
73 */ 80 */
74QString WExtensions::mode(){ 81QString WExtensions::mode(){
75 if(!hasWirelessExtensions) 82 if(!hasWirelessExtensions)
76 return QString(); 83 return QString();
77 if ( 0 == ioctl( fd, SIOCGIWMODE, &iwr ) ) 84 if ( 0 == ioctl( fd, SIOCGIWMODE, &iwr ) )
78 return QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed"); 85 return QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed");
79 return QString(); 86 return QString();
80} 87}
81 88
82/** 89/**
83 * Get the frequency that the interface is running at. 90 * Get the frequency that the interface is running at.
84 * @return int the frequency that the interfacae is running at. 91 * @return int the frequency that the interfacae is running at.
85 */ 92 */
86double WExtensions::frequency(){ 93double WExtensions::frequency(){
87 if(!hasWirelessExtensions) 94 if(!hasWirelessExtensions)
88 return 0; 95 return 0;
89 if ( 0 == ioctl( fd, SIOCGIWFREQ, &iwr )) 96 if ( 0 == ioctl( fd, SIOCGIWFREQ, &iwr ))
90 return (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); 97 return (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000);
91 return 0; 98 return 0;
92} 99}
93 100
94/** 101/**
95 * Get the channel that the interface is running at. 102 * Get the channel that the interface is running at.
96 * @return int the channel that the interfacae is running at. 103 * @return int the channel that the interfacae is running at.
97 */ 104 */
98int WExtensions::channel(){ 105int WExtensions::channel(){
99 if(!hasWirelessExtensions) 106 if(!hasWirelessExtensions)
100 return 0; 107 return 0;
101 if ( 0 != ioctl( fd, SIOCGIWFREQ, &iwr )) 108 if ( 0 != ioctl( fd, SIOCGIWFREQ, &iwr ))
102 return 0; 109 return 0;
103 110
104 // http://www.elanix.com/pdf/an137e.pdf 111 // http://www.elanix.com/pdf/an137e.pdf
105 112
106 double num = (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); 113 double num = (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000);
107 double left = 2.401; 114 double left = 2.401;
108 double right = 2.416; 115 double right = 2.416;
109 for(int channel = 1; channel<= 15; channel++){ 116 for(int channel = 1; channel<= 15; channel++){
110 if( num >= left && num <= right ) 117 if( num >= left && num <= right )
111 return channel; 118 return channel;
112 left += 0.005; 119 left += 0.005;
113 right += 0.005; 120 right += 0.005;
114 } 121 }
115 odebug << QString("Unknown frequency: %1, returning -1 for the channel.").arg(num).latin1() << oendl; 122 odebug << QString("Unknown frequency: %1, returning -1 for the channel.").arg(num).latin1() << oendl;
116 return -1; 123 return -1;
117} 124}
118 125
119/*** 126/***
120 * Get the current rate that the card is transmiting at. 127 * Get the current rate that the card is transmiting at.
121 * @return double the rate, 0 if error. 128 * @return double the rate, 0 if error.
122 */ 129 */
123double WExtensions::rate(){ 130double WExtensions::rate(){
124 if(!hasWirelessExtensions) 131 if(!hasWirelessExtensions)
125 return 0; 132 return 0;
126 if(0 == ioctl(fd, SIOCGIWRATE, &iwr)){ 133 if(0 == ioctl(fd, SIOCGIWRATE, &iwr)){
127 return ((double)iwr.u.bitrate.value)/1000000; 134 return ((double)iwr.u.bitrate.value)/1000000;
128 } 135 }
129 return 0; 136 return 0;
130} 137}
131 138
132 139
133/** 140/**
134 * @return QString the AccessPoint that the interface is connected to. 141 * @return QString the AccessPoint that the interface is connected to.
135 */ 142 */
136QString WExtensions::ap(){ 143QString WExtensions::ap(){
137 if(!hasWirelessExtensions) 144 if(!hasWirelessExtensions)
138 return QString(); 145 return QString();
139 if ( 0 == ioctl( fd, SIOCGIWAP, &iwr )){ 146 if ( 0 == ioctl( fd, SIOCGIWAP, &iwr )){
140 QString ap; 147 QString ap;
141 ap = ap.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", 148 ap = ap.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X",
142 iwr.u.ap_addr.sa_data[0]&0xff, 149 iwr.u.ap_addr.sa_data[0]&0xff,
143 iwr.u.ap_addr.sa_data[1]&0xff, 150 iwr.u.ap_addr.sa_data[1]&0xff,
144 iwr.u.ap_addr.sa_data[2]&0xff, 151 iwr.u.ap_addr.sa_data[2]&0xff,
145 iwr.u.ap_addr.sa_data[3]&0xff, 152 iwr.u.ap_addr.sa_data[3]&0xff,
146 iwr.u.ap_addr.sa_data[4]&0xff, 153 iwr.u.ap_addr.sa_data[4]&0xff,
147 iwr.u.ap_addr.sa_data[5]&0xff ); 154 iwr.u.ap_addr.sa_data[5]&0xff );
148 return ap; 155 return ap;
149 } 156 }
150 else return QString(); 157 else return QString();
151} 158}
152 159
153/** 160/**
154 * Get the stats for interfaces 161 * Get the stats for interfaces
155 * @param signal the signal strength of interface 162 * @param signal the signal strength of interface
156 * @param noise the noise level of the interface 163 * @param noise the noise level of the interface
157 * @param quality the quality level of the interface 164 * @param quality the quality level of the interface
158 * @return bool true if successful 165 * @return bool true if successful
159 */ 166 */
160bool WExtensions::stats(int &signal, int &noise, int &quality){ 167bool WExtensions::stats(int &signal, int &noise, int &quality){
161 // gather link quality from /proc/net/wireless 168 // gather link quality from /proc/net/wireless
162 if(!QFile::exists(PROCNETWIRELESS)) 169 if(!QFile::exists(PROCNETWIRELESS))
163 return false; 170 return false;
164 171
165 char c; 172 char c;
166 QString status; 173 QString status;
167 QString name; 174 QString name;
168 175
169 QFile wfile( PROCNETWIRELESS ); 176 QFile wfile( PROCNETWIRELESS );
170 if(!wfile.open( IO_ReadOnly )) 177 if(!wfile.open( IO_ReadOnly ))
171 return false; 178 return false;
172 179
173 QTextStream wstream( &wfile ); 180 QTextStream wstream( &wfile );
174 wstream.readLine(); // skip the first two lines 181 wstream.readLine(); // skip the first two lines
175 wstream.readLine(); // because they only contain headers 182 wstream.readLine(); // because they only contain headers
176 while(!wstream.atEnd()){ 183 while(!wstream.atEnd()){
177 wstream >> name >> status >> quality >> c >> signal >> c >> noise; 184 wstream >> name >> status >> quality >> c >> signal >> c >> noise;
178 if(name == QString("%1:").arg(interface)){ 185 if(name == QString("%1:").arg(interface)){
179 if ( quality > 92 ) 186 if ( quality > 92 )
180 odebug << "WIFIAPPLET: D'oh! Quality " << quality << " > estimated max!\n" << oendl; 187 odebug << "WIFIAPPLET: D'oh! Quality " << quality << " > estimated max!\n" << oendl;
181 if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) 188 if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) )
182 odebug << "WIFIAPPLET: Doh! Strength " << signal << " > estimated max!\n" << oendl; 189 odebug << "WIFIAPPLET: Doh! Strength " << signal << " > estimated max!\n" << oendl;
183 if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) 190 if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) )
184 odebug << "WIFIAPPLET: Doh! Noise " << noise << " > estimated max!\n" << oendl; 191 odebug << "WIFIAPPLET: Doh! Noise " << noise << " > estimated max!\n" << oendl;
185 //odebug << QString("q:%1, s:%2, n:%3").arg(quality).arg(signal).arg(noise).latin1() << oendl; 192 //odebug << QString("q:%1, s:%2, n:%3").arg(quality).arg(signal).arg(noise).latin1() << oendl;
186 signal = ( ( signal-IW_LOWER ) * 100 ) / IW_UPPER; 193 signal = ( ( signal-IW_LOWER ) * 100 ) / IW_UPPER;
187 noise = ( ( noise-IW_LOWER ) * 100 ) / IW_UPPER; 194 noise = ( ( noise-IW_LOWER ) * 100 ) / IW_UPPER;
188 quality = ( quality*100 ) / 92; 195 quality = ( quality*100 ) / 92;
189 return true; 196 return true;
190 } 197 }
191 } 198 }
192 199
193 odebug << "WExtensions::statsCard no longer present." << oendl; 200 odebug << "WExtensions::statsCard no longer present." << oendl;
194 quality = -1; 201 quality = -1;
195 signal = IW_LOWER; 202 signal = IW_LOWER;
196 noise = IW_LOWER; 203 noise = IW_LOWER;
197 return false; 204 return false;
198} 205}
199 206
200// wextensions.cpp 207// wextensions.cpp
diff --git a/noncore/settings/networksettings/wlan/wlan.pro b/noncore/settings/networksettings/wlan/wlan.pro
index 89867ae..c94dc0e 100644
--- a/noncore/settings/networksettings/wlan/wlan.pro
+++ b/noncore/settings/networksettings/wlan/wlan.pro
@@ -1,28 +1,25 @@
1#
2TEMPLATE = lib 1TEMPLATE = lib
3#TEMPLATE = app
4CONFIG += qt plugin warn_on 2CONFIG += qt plugin warn_on
5 #CONFIG += qt plugin warn_on
6DESTDIR = $(OPIEDIR)/plugins/networksettings 3DESTDIR = $(OPIEDIR)/plugins/networksettings
7 HEADERS = infoimp.h wlanmodule.h wextensions.h keyedit.h 4 HEADERS = infoimp.h wlanmodule.h wextensions.h keyedit.h
8 SOURCES = infoimp.cpp wlanmodule.cpp wextensions.cpp keyedit.cpp 5 SOURCES = infoimp.cpp wlanmodule.cpp wextensions.cpp keyedit.cpp
9 INCLUDEPATH+= $(OPIEDIR)/include ../ ../interfaces/ 6 INCLUDEPATH+= $(OPIEDIR)/include ../ ../interfaces/
10 DEPENDPATH+= $(OPIEDIR)/include 7 DEPENDPATH+= $(OPIEDIR)/include
11LIBS += -lqpe -L../interfaces/ -linterfaces -lopiecore2 -lopienet2 8LIBS += -lqpe -L../interfaces/ -linterfaces -lopiecore2 -lopienet2
12 INTERFACES= wlan.ui info.ui 9 INTERFACES= wlan.ui info.ui
13 TARGET = wlan 10 TARGET = wlan
14 VERSION = 1.0.0 11 VERSION = 1.0.0
15 12
16#CONFIG += wirelessopts 13#CONFIG += wirelessopts
17 14
18wirelessopts { 15wirelessopts {
19 HEADERS+= wlanimp.h 16 HEADERS+= wlanimp.h
20 SOURCES+= wlanimp.cpp 17 SOURCES+= wlanimp.cpp
21} 18}
22 19
23! wirelessopts { 20! wirelessopts {
24 HEADERS+= wlanimp2.h 21 HEADERS+= wlanimp2.h
25 SOURCES += wlanimp2.cpp 22 SOURCES += wlanimp2.cpp
26} 23}
27 24
28include ( $(OPIEDIR)/include.pro ) 25include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/settings/networksettings/wlan/wlanimp2.cpp b/noncore/settings/networksettings/wlan/wlanimp2.cpp
index e4aa2f9..4294b12 100644
--- a/noncore/settings/networksettings/wlan/wlanimp2.cpp
+++ b/noncore/settings/networksettings/wlan/wlanimp2.cpp
@@ -1,492 +1,494 @@
1#include "wlanimp2.h" 1#include "wlanimp2.h"
2#include "keyedit.h" 2#include "keyedit.h"
3#include "interfacesetupimp.h" 3#include "interfacesetupimp.h"
4
5#include "../interfaces/interface.h" 4#include "../interfaces/interface.h"
6 5
7#include <assert.h> 6#include <assert.h>
8#include <errno.h> 7#include <errno.h>
9#include <string.h> 8#include <string.h>
10 9
10/* OPIE */
11#include <opie2/odebug.h>
12#include <opie2/oprocess.h>
13#include <opie2/onetwork.h>
14#include <opie2/opcap.h>
15#include <qpe/resource.h>
16using namespace Opie::Core;
17using namespace Opie::Net;
18
19/* QT */
11#include <qapplication.h> 20#include <qapplication.h>
12#include <qfile.h> 21#include <qfile.h>
13#include <qdir.h> 22#include <qdir.h>
14#include <qdialog.h> 23#include <qdialog.h>
15#include <qtextstream.h> 24#include <qtextstream.h>
16#include <qmessagebox.h> 25#include <qmessagebox.h>
17#include <qlineedit.h> 26#include <qlineedit.h>
18#include <qlabel.h> 27#include <qlabel.h>
19#include <qspinbox.h> 28#include <qspinbox.h>
20#include <qradiobutton.h> 29#include <qradiobutton.h>
21#include <qpushbutton.h> 30#include <qpushbutton.h>
22#include <qcheckbox.h> 31#include <qcheckbox.h>
23#include <qtabwidget.h> 32#include <qtabwidget.h>
24#include <qcombobox.h> 33#include <qcombobox.h>
25#include <qlistview.h> 34#include <qlistview.h>
26#include <qvbox.h> 35#include <qvbox.h>
27#include <qprogressbar.h> 36#include <qprogressbar.h>
28 37
29#ifdef QWS 38/* STD */
30 #include <qpe/resource.h> 39#include <assert.h>
31 #include <opie2/oprocess.h> 40#include <errno.h>
32 #include <opie2/onetwork.h> 41#include <string.h>
33 #include <opie2/opcap.h>
34#else
35 #define OProcess KProcess
36 #include <kprocess.h>
37#endif
38 42
39#define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" 43#define WIRELESS_OPTS "/etc/pcmcia/wireless.opts"
40#define PREUP "/etc/network/if-pre-up.d/wireless-tools" 44#define PREUP "/etc/network/if-pre-up.d/wireless-tools"
41 45
42/** 46/**
43 * Constructor, read in the wireless.opts file for parsing later. 47 * Constructor, read in the wireless.opts file for parsing later.
44 */ 48 */
45using namespace Opie::Net;
46using namespace Opie::Core;
47WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : WLAN(parent, name, modal, fl), interface(i), currentProfile("*") { 49WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : WLAN(parent, name, modal, fl), interface(i), currentProfile("*") {
48 interfaces = new Interfaces(); 50 interfaces = new Interfaces();
49 interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, interfaces); 51 interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, interfaces);
50 tabWidget->insertTab(interfaceSetup, "TCP/IP"); 52 tabWidget->insertTab(interfaceSetup, "TCP/IP");
51 53
52 // Check sanity - the existance of the wireless-tools if-pre-up script 54 // Check sanity - the existance of the wireless-tools if-pre-up script
53 QFile file(QString(PREUP)); 55 QFile file(QString(PREUP));
54 if (file.exists()) { 56 if (file.exists()) {
55 owarn << QString("WLANImp: Unable to open /etc/network/if-pre-up.d/wireless-tools") << oendl; 57 owarn << QString("WLANImp: Unable to open /etc/network/if-pre-up.d/wireless-tools") << oendl;
56 } 58 }
57 59
58 connect( rescanButton, SIGNAL( clicked() ), this, SLOT( rescanNeighbourhood() ) ); 60 connect( rescanButton, SIGNAL( clicked() ), this, SLOT( rescanNeighbourhood() ) );
59 connect( netView, SIGNAL( clicked(QListViewItem*) ), this, SLOT( selectNetwork(QListViewItem*) ) ); 61 connect( netView, SIGNAL( clicked(QListViewItem*) ), this, SLOT( selectNetwork(QListViewItem*) ) );
60 netView->setColumnAlignment( col_chn, AlignCenter ); 62 netView->setColumnAlignment( col_chn, AlignCenter );
61 netView->setItemMargin( 3 ); 63 netView->setItemMargin( 3 );
62 netView->setAllColumnsShowFocus( true ); 64 netView->setAllColumnsShowFocus( true );
63 65
64} 66}
65 67
66WLANImp::~WLANImp() { 68WLANImp::~WLANImp() {
67//FIXME: delete interfaces; 69//FIXME: delete interfaces;
68} 70}
69 71
70/** 72/**
71 * Change the profile for both wireless settings and network settings. 73 * Change the profile for both wireless settings and network settings.
72 */ 74 */
73void WLANImp::setProfile(const QString &profile){ 75void WLANImp::setProfile(const QString &profile){
74 interfaceSetup->setProfile(profile); 76 interfaceSetup->setProfile(profile);
75 parseOpts(); 77 parseOpts();
76} 78}
77 79
78void WLANImp::parseOpts() { 80void WLANImp::parseOpts() {
79 bool error; 81 bool error;
80 QString opt; 82 QString opt;
81 83
82 if (! interfaces->isInterfaceSet()) 84 if (! interfaces->isInterfaceSet())
83 return; 85 return;
84 86
85 87
86 opt = interfaces->getInterfaceOption("wireless_essid", error); 88 opt = interfaces->getInterfaceOption("wireless_essid", error);
87 if(opt == "any" || opt == "off" || opt.isNull()){ 89 if(opt == "any" || opt == "off" || opt.isNull()){
88 essid->setEditText("any"); 90 essid->setEditText("any");
89 } else { 91 } else {
90 essid->setEditText(opt); 92 essid->setEditText(opt);
91 } 93 }
92 94
93 opt = interfaces->getInterfaceOption("wireless_mode", error).simplifyWhiteSpace(); 95 opt = interfaces->getInterfaceOption("wireless_mode", error).simplifyWhiteSpace();
94 96
95 for ( int i = 0; i < mode->count(); i++) 97 for ( int i = 0; i < mode->count(); i++)
96 if ( mode->text( i ) == opt ) mode->setCurrentItem( i ); 98 if ( mode->text( i ) == opt ) mode->setCurrentItem( i );
97 99
98 opt = interfaces->getInterfaceOption("wireless_ap", error).simplifyWhiteSpace(); 100 opt = interfaces->getInterfaceOption("wireless_ap", error).simplifyWhiteSpace();
99 if (! opt.isNull()) { 101 if (! opt.isNull()) {
100 specifyAp->setChecked(true); 102 specifyAp->setChecked(true);
101 macEdit->setText(opt); 103 macEdit->setText(opt);
102 } 104 }
103 105
104 opt = interfaces->getInterfaceOption("wireless_channel", error).simplifyWhiteSpace(); 106 opt = interfaces->getInterfaceOption("wireless_channel", error).simplifyWhiteSpace();
105 if (! opt.isNull()) { 107 if (! opt.isNull()) {
106 specifyChan->setChecked(true); 108 specifyChan->setChecked(true);
107 networkChannel->setValue(opt.toInt()); 109 networkChannel->setValue(opt.toInt());
108 } 110 }
109 111
110 opt = interfaces->getInterfaceOption("wireless_key", error).simplifyWhiteSpace(); 112 opt = interfaces->getInterfaceOption("wireless_key", error).simplifyWhiteSpace();
111 if (opt.isNull()) 113 if (opt.isNull())
112 opt = interfaces->getInterfaceOption("wireless_enc", error).simplifyWhiteSpace(); 114 opt = interfaces->getInterfaceOption("wireless_enc", error).simplifyWhiteSpace();
113 parseKeyStr(opt); 115 parseKeyStr(opt);
114} 116}
115 117
116void WLANImp::parseKeyStr(QString keystr) { 118void WLANImp::parseKeyStr(QString keystr) {
117 int loc = 0; 119 int loc = 0;
118 int index = 1; 120 int index = 1;
119 QString key; 121 QString key;
120 QStringList keys = QStringList::split(QRegExp("\\s+"), keystr); 122 QStringList keys = QStringList::split(QRegExp("\\s+"), keystr);
121 int enc = -1; // encryption state 123 int enc = -1; // encryption state
122 124
123 for (QStringList::Iterator it = keys.begin(); it != keys.end(); ++it) { 125 for (QStringList::Iterator it = keys.begin(); it != keys.end(); ++it) {
124 if ((*it).left(3) == "off") { 126 if ((*it).left(3) == "off") {
125 // encryption disabled 127 // encryption disabled
126 enc = 0; 128 enc = 0;
127 } else if ((*it).left(2) == "on") { 129 } else if ((*it).left(2) == "on") {
128 // encryption enabled 130 // encryption enabled
129 enc = 1; 131 enc = 1;
130 } else if ((*it).left(4) == "open") { 132 } else if ((*it).left(4) == "open") {
131 // open mode, accept non encrypted packets 133 // open mode, accept non encrypted packets
132 acceptNonEnc->setChecked(true); 134 acceptNonEnc->setChecked(true);
133 } else if ((*it).left(10) == "restricted") { 135 } else if ((*it).left(10) == "restricted") {
134 // restricted mode, only accept encrypted packets 136 // restricted mode, only accept encrypted packets
135 rejectNonEnc->setChecked(true); 137 rejectNonEnc->setChecked(true);
136 } else if ((*it).left(3) == "key") { 138 } else if ((*it).left(3) == "key") {
137 // new set of options 139 // new set of options
138 } else if ((*it).left(1) == "[") { 140 } else if ((*it).left(1) == "[") {
139 index = (*it).mid(1, 1).toInt(); 141 index = (*it).mid(1, 1).toInt();
140 // switch current key to index 142 // switch current key to index
141 switch (index) { 143 switch (index) {
142 case 1: 144 case 1:
143 keyRadio0->setChecked(true); 145 keyRadio0->setChecked(true);
144 break; 146 break;
145 case 2: 147 case 2:
146 keyRadio1->setChecked(true); 148 keyRadio1->setChecked(true);
147 break; 149 break;
148 case 3: 150 case 3:
149 keyRadio2->setChecked(true); 151 keyRadio2->setChecked(true);
150 break; 152 break;
151 case 4: 153 case 4:
152 keyRadio3->setChecked(true); 154 keyRadio3->setChecked(true);
153 break; 155 break;
154 } 156 }
155 } else { 157 } else {
156 // key 158 // key
157 key = (*it); 159 key = (*it);
158 } 160 }
159 if (! key.isNull()) { 161 if (! key.isNull()) {
160 if (enc == -1) 162 if (enc == -1)
161 enc = 1; 163 enc = 1;
162 QStringList::Iterator next = ++it; 164 QStringList::Iterator next = ++it;
163 if (it == keys.end()) { 165 if (it == keys.end()) {
164 break; 166 break;
165 } 167 }
166 if ((*(next)).left(1) == "[") { 168 if ((*(next)).left(1) == "[") {
167 // set key at index 169 // set key at index
168 index = (*(next)).mid(1, 1).toInt(); 170 index = (*(next)).mid(1, 1).toInt();
169 } else { 171 } else {
170 index = 1; 172 index = 1;
171 } 173 }
172 switch (index) { 174 switch (index) {
173 case 1: 175 case 1:
174 keyLineEdit0->setText(key); 176 keyLineEdit0->setText(key);
175 break; 177 break;
176 case 2: 178 case 2:
177 keyLineEdit1->setText(key); 179 keyLineEdit1->setText(key);
178 break; 180 break;
179 case 3: 181 case 3:
180 keyLineEdit2->setText(key); 182 keyLineEdit2->setText(key);
181 break; 183 break;
182 case 4: 184 case 4:
183 keyLineEdit3->setText(key); 185 keyLineEdit3->setText(key);
184 break; 186 break;
185 } 187 }
186 key = QString::null; 188 key = QString::null;
187 } 189 }
188 } 190 }
189 if (enc == 1) { 191 if (enc == 1) {
190 wepEnabled->setChecked(true); 192 wepEnabled->setChecked(true);
191 } else { 193 } else {
192 wepEnabled->setChecked(false); 194 wepEnabled->setChecked(false);
193 } 195 }
194} 196}
195 197
196/** 198/**
197 * Check to see if the current config is valid 199 * Check to see if the current config is valid
198 * Save interfaces 200 * Save interfaces
199 */ 201 */
200void WLANImp::accept() { 202void WLANImp::accept() {
201 if (wepEnabled->isChecked()) { 203 if (wepEnabled->isChecked()) {
202 if ((keyRadio0->isChecked() && keyLineEdit0->text().isEmpty()) || 204 if ((keyRadio0->isChecked() && keyLineEdit0->text().isEmpty()) ||
203 (keyRadio1->isChecked() && keyLineEdit1->text().isEmpty()) || 205 (keyRadio1->isChecked() && keyLineEdit1->text().isEmpty()) ||
204 (keyRadio2->isChecked() && keyLineEdit2->text().isEmpty()) || 206 (keyRadio2->isChecked() && keyLineEdit2->text().isEmpty()) ||
205 (keyRadio3->isChecked() && keyLineEdit3->text().isEmpty())) { 207 (keyRadio3->isChecked() && keyLineEdit3->text().isEmpty())) {
206 QMessageBox::information(this, "Error", "Please enter a WEP key.", QMessageBox::Ok); 208 QMessageBox::information(this, "Error", "Please enter a WEP key.", QMessageBox::Ok);
207 return; 209 return;
208 } 210 }
209 } 211 }
210 212
211 if (essid->currentText().isEmpty()) { 213 if (essid->currentText().isEmpty()) {
212 QMessageBox::information(this, "Error", "Please select/enter an ESSID.", QMessageBox::Ok); 214 QMessageBox::information(this, "Error", "Please select/enter an ESSID.", QMessageBox::Ok);
213 return; 215 return;
214 } 216 }
215 217
216 if (specifyAp->isChecked() && macEdit->text().isEmpty()) { 218 if (specifyAp->isChecked() && macEdit->text().isEmpty()) {
217 QMessageBox::information(this, "Error", "Please enter the MAC address of the Access Point.", QMessageBox::Ok); 219 QMessageBox::information(this, "Error", "Please enter the MAC address of the Access Point.", QMessageBox::Ok);
218 return; 220 return;
219 } 221 }
220 222
221 // Try to save the interfaces settings. 223 // Try to save the interfaces settings.
222 writeOpts(); 224 writeOpts();
223 225
224 // Close out the dialog 226 // Close out the dialog
225// FIXME: QDialog::accept(); 227// FIXME: QDialog::accept();
226} 228}
227 229
228void WLANImp::writeOpts() { 230void WLANImp::writeOpts() {
229 // eh can't really do anything about it other then return. :-D 231 // eh can't really do anything about it other then return. :-D
230 if(!interfaces->isInterfaceSet()){ 232 if(!interfaces->isInterfaceSet()){
231 QMessageBox::warning(0,"Inface not set","should not happen!!!"); 233 QMessageBox::warning(0,"Inface not set","should not happen!!!");
232 return; 234 return;
233 } 235 }
234 bool error = false; 236 bool error = false;
235 237
236 odebug << "setting wlan interface " << interfaces->getInterfaceName( error ).latin1() << "" << oendl; 238 odebug << "setting wlan interface " << interfaces->getInterfaceName( error ).latin1() << "" << oendl;
237 239
238 if (error) QMessageBox::warning(0,"Inface not set","should not happen!!!"); 240 if (error) QMessageBox::warning(0,"Inface not set","should not happen!!!");
239 241
240 interfaces->setInterfaceOption(QString("wireless_mode"), mode->currentText()); 242 interfaces->setInterfaceOption(QString("wireless_mode"), mode->currentText());
241 interfaces->setInterfaceOption(QString("wireless_essid"), essid->currentText()); 243 interfaces->setInterfaceOption(QString("wireless_essid"), essid->currentText());
242 244
243 if (specifyAp->isChecked()) { 245 if (specifyAp->isChecked()) {
244 interfaces->setInterfaceOption(QString("wireless_ap"), macEdit->text()); 246 interfaces->setInterfaceOption(QString("wireless_ap"), macEdit->text());
245 } else { 247 } else {
246 interfaces->removeInterfaceOption(QString("wireless_ap")); 248 interfaces->removeInterfaceOption(QString("wireless_ap"));
247 } 249 }
248 250
249 if (specifyChan->isChecked()) { 251 if (specifyChan->isChecked()) {
250 interfaces->setInterfaceOption(QString("wireless_channel"), networkChannel->text()); 252 interfaces->setInterfaceOption(QString("wireless_channel"), networkChannel->text());
251 } else { 253 } else {
252 interfaces->removeInterfaceOption(QString("wireless_channel")); 254 interfaces->removeInterfaceOption(QString("wireless_channel"));
253 } 255 }
254 256
255 if (wepEnabled->isChecked()) { 257 if (wepEnabled->isChecked()) {
256 QStringList keyList; 258 QStringList keyList;
257 259
258 if (! keyLineEdit0->text().isNull()) { 260 if (! keyLineEdit0->text().isNull()) {
259 keyList += keyLineEdit0->text(); 261 keyList += keyLineEdit0->text();
260 keyList += "[1]"; 262 keyList += "[1]";
261 } //else 263 } //else
262 if (! keyLineEdit1->text().isNull()) { 264 if (! keyLineEdit1->text().isNull()) {
263 keyList += keyLineEdit1->text(); 265 keyList += keyLineEdit1->text();
264 keyList += "[2]"; 266 keyList += "[2]";
265 } //else 267 } //else
266 if (! keyLineEdit2->text().isNull()) { 268 if (! keyLineEdit2->text().isNull()) {
267 keyList += keyLineEdit2->text(); 269 keyList += keyLineEdit2->text();
268 keyList += "[3]"; 270 keyList += "[3]";
269 } //else 271 } //else
270 if (! keyLineEdit3->text().isNull()) { 272 if (! keyLineEdit3->text().isNull()) {
271 keyList += keyLineEdit3->text(); 273 keyList += keyLineEdit3->text();
272 keyList += "[4]"; 274 keyList += "[4]";
273 } 275 }
274 if (acceptNonEnc->isChecked()) { 276 if (acceptNonEnc->isChecked()) {
275 keyList += "open"; 277 keyList += "open";
276 } else { 278 } else {
277 keyList += "restricted"; 279 keyList += "restricted";
278 } 280 }
279 281
280 keyList += "key"; 282 keyList += "key";
281 if (keyRadio0->isChecked()) { 283 if (keyRadio0->isChecked()) {
282 keyList += "[1]"; 284 keyList += "[1]";
283 } else if (keyRadio1->isChecked()) { 285 } else if (keyRadio1->isChecked()) {
284 keyList += "[2]"; 286 keyList += "[2]";
285 } else if (keyRadio2->isChecked()) { 287 } else if (keyRadio2->isChecked()) {
286 keyList += "[3]"; 288 keyList += "[3]";
287 } else if (keyRadio3->isChecked()) { 289 } else if (keyRadio3->isChecked()) {
288 keyList += "[4]"; 290 keyList += "[4]";
289 } 291 }
290 interfaces->setInterfaceOption(QString("wireless_key"), keyList.join(QString(" "))); 292 interfaces->setInterfaceOption(QString("wireless_key"), keyList.join(QString(" ")));
291 } else { 293 } else {
292 interfaces->removeInterfaceOption(QString("wireless_key")); 294 interfaces->removeInterfaceOption(QString("wireless_key"));
293 } 295 }
294 interfaces->removeInterfaceOption(QString("wireless_enc")); 296 interfaces->removeInterfaceOption(QString("wireless_enc"));
295 297
296 if(!interfaceSetup->saveChanges()) 298 if(!interfaceSetup->saveChanges())
297 return; 299 return;
298 300
299 QDialog::accept(); 301 QDialog::accept();
300} 302}
301 303
302/* 304/*
303 * Scan for possible wireless networks around... 305 * Scan for possible wireless networks around...
304 * ... powered by Wellenreiter II technology (C) Michael 'Mickey' Lauer <mickeyl@handhelds.org> 306 * ... powered by Wellenreiter II technology (C) Michael 'Mickey' Lauer <mickeyl@handhelds.org>
305 */ 307 */
306 308
307void WLANImp::rescanNeighbourhood() 309void WLANImp::rescanNeighbourhood()
308{ 310{
309 QString name = interface->getInterfaceName(); 311 QString name = interface->getInterfaceName();
310 odebug << "rescanNeighbourhood via '" << name << "'" << oendl; 312 odebug << "rescanNeighbourhood via '" << name << "'" << oendl;
311 313
312 OWirelessNetworkInterface* wiface = static_cast<OWirelessNetworkInterface*>( ONetwork::instance()->interface( name ) ); 314 OWirelessNetworkInterface* wiface = static_cast<OWirelessNetworkInterface*>( ONetwork::instance()->interface( name ) );
313 assert( wiface ); 315 assert( wiface );
314 316
315 // try to guess device type 317 // try to guess device type
316 QString devicetype; 318 QString devicetype;
317 QFile m( "/proc/modules" ); 319 QFile m( "/proc/modules" );
318 if ( m.open( IO_ReadOnly ) ) 320 if ( m.open( IO_ReadOnly ) )
319 { 321 {
320 QString line; 322 QString line;
321 QTextStream modules( &m ); 323 QTextStream modules( &m );
322 while( !modules.atEnd() && !devicetype ) 324 while( !modules.atEnd() && !devicetype )
323 { 325 {
324 modules >> line; 326 modules >> line;
325 if ( line.contains( "cisco" ) ) devicetype = "cisco"; 327 if ( line.contains( "cisco" ) ) devicetype = "cisco";
326 else if ( line.contains( "hostap" ) ) devicetype = "hostap"; 328 else if ( line.contains( "hostap" ) ) devicetype = "hostap";
327 else if ( line.contains( "prism" ) ) devicetype = "wlan-ng"; /* puke */ 329 else if ( line.contains( "prism" ) ) devicetype = "wlan-ng"; /* puke */
328 else if ( line.contains( "orinoco" ) ) devicetype = "orinoco"; 330 else if ( line.contains( "orinoco" ) ) devicetype = "orinoco";
329 } 331 }
330 } 332 }
331 if ( devicetype.isEmpty() ) 333 if ( devicetype.isEmpty() )
332 { 334 {
333 owarn << "rescanNeighbourhood(): couldn't guess device type :(" << oendl; 335 owarn << "rescanNeighbourhood(): couldn't guess device type :(" << oendl;
334 return; 336 return;
335 } 337 }
336 else 338 else
337 { 339 {
338 odebug << "rescanNeighbourhood(): device type seems to be '" << devicetype << "'" << oendl; 340 odebug << "rescanNeighbourhood(): device type seems to be '" << devicetype << "'" << oendl;
339 } 341 }
340 342
341 // configure interface to receive 802.11 management frames 343 // configure interface to receive 802.11 management frames
342 344
343 wiface->setUp( true ); 345 wiface->setUp( true );
344 wiface->setPromiscuousMode( true ); 346 wiface->setPromiscuousMode( true );
345 347
346 if ( devicetype == "cisco" ) wiface->setMonitoring( new OCiscoMonitoringInterface( wiface, false ) ); 348 if ( devicetype == "cisco" ) wiface->setMonitoring( new OCiscoMonitoringInterface( wiface, false ) );
347 else if ( devicetype == "hostap" ) wiface->setMonitoring( new OHostAPMonitoringInterface( wiface, false ) ); 349 else if ( devicetype == "hostap" ) wiface->setMonitoring( new OHostAPMonitoringInterface( wiface, false ) );
348 else if ( devicetype == "wlan-ng" ) wiface->setMonitoring( new OWlanNGMonitoringInterface( wiface, false ) ); 350 else if ( devicetype == "wlan-ng" ) wiface->setMonitoring( new OWlanNGMonitoringInterface( wiface, false ) );
349 else if ( devicetype == "orinoco" ) wiface->setMonitoring( new OOrinocoMonitoringInterface( wiface, false ) ); 351 else if ( devicetype == "orinoco" ) wiface->setMonitoring( new OOrinocoMonitoringInterface( wiface, false ) );
350 else 352 else
351 { 353 {
352 odebug << "rescanNeighbourhood(): unsupported device type for monitoring :(" << oendl; 354 odebug << "rescanNeighbourhood(): unsupported device type for monitoring :(" << oendl;
353 return; 355 return;
354 } 356 }
355 357
356 wiface->setMode( "monitor" ); 358 wiface->setMode( "monitor" );
357 if ( wiface->mode() != "monitor" ) 359 if ( wiface->mode() != "monitor" )
358 { 360 {
359 owarn << "rescanNeighbourhood(): Unable to bring device into monitor mode (" << strerror( errno ) << ")." << oendl; 361 owarn << "rescanNeighbourhood(): Unable to bring device into monitor mode (" << strerror( errno ) << ")." << oendl;
360 return; 362 return;
361 } 363 }
362 364
363 // open a packet capturer 365 // open a packet capturer
364 OPacketCapturer* cap = new OPacketCapturer(); 366 OPacketCapturer* cap = new OPacketCapturer();
365 cap->open( name ); 367 cap->open( name );
366 if ( !cap->isOpen() ) 368 if ( !cap->isOpen() )
367 { 369 {
368 owarn << "rescanNeighbourhood(): Unable to open libpcap (" << strerror( errno ) << ")." << oendl; 370 owarn << "rescanNeighbourhood(): Unable to open libpcap (" << strerror( errno ) << ")." << oendl;
369 return; 371 return;
370 } 372 }
371 373
372 // display splash screen 374 // display splash screen
373 QFrame* splash = new QFrame( this, "splash", false, WStyle_StaysOnTop | WStyle_DialogBorder | WStyle_Customize ); 375 QFrame* splash = new QFrame( this, "splash", false, WStyle_StaysOnTop | WStyle_DialogBorder | WStyle_Customize );
374 splash->setLineWidth( 2 ); 376 splash->setLineWidth( 2 );
375 splash->setFrameStyle( QFrame::Panel | QFrame::Raised ); 377 splash->setFrameStyle( QFrame::Panel | QFrame::Raised );
376 QVBoxLayout* vbox = new QVBoxLayout( splash, 4, 4 ); 378 QVBoxLayout* vbox = new QVBoxLayout( splash, 4, 4 );
377 QLabel* lab = new QLabel( "<center><b>Scanning...</b><br>Please Wait...</center>", splash ); 379 QLabel* lab = new QLabel( "<center><b>Scanning...</b><br>Please Wait...</center>", splash );
378 QProgressBar* pb = new QProgressBar( wiface->channels(), splash ); 380 QProgressBar* pb = new QProgressBar( wiface->channels(), splash );
379 vbox->addWidget( lab ); 381 vbox->addWidget( lab );
380 vbox->addWidget( pb ); 382 vbox->addWidget( pb );
381 pb->setCenterIndicator( true ); 383 pb->setCenterIndicator( true );
382 pb->setFixedHeight( pb->sizeHint().height() ); 384 pb->setFixedHeight( pb->sizeHint().height() );
383 QWidget* widgetDesktop = qApp->desktop(); 385 QWidget* widgetDesktop = qApp->desktop();
384 int dw = widgetDesktop->width(); 386 int dw = widgetDesktop->width();
385 int dh = widgetDesktop->height(); 387 int dh = widgetDesktop->height();
386 int pw = vbox->sizeHint().width(); 388 int pw = vbox->sizeHint().width();
387 int ph = vbox->sizeHint().height(); 389 int ph = vbox->sizeHint().height();
388 splash->setGeometry((dw-pw)/2,(dh-ph)/2,pw,ph); 390 splash->setGeometry((dw-pw)/2,(dh-ph)/2,pw,ph);
389 splash->show(); 391 splash->show();
390 splash->raise(); 392 splash->raise();
391 qApp->processEvents(); 393 qApp->processEvents();
392 394
393 // set capturer to non-blocking mode 395 // set capturer to non-blocking mode
394 cap->setBlocking( false ); 396 cap->setBlocking( false );
395 397
396 for ( int i = 1; i <= wiface->channels(); ++i ) 398 for ( int i = 1; i <= wiface->channels(); ++i )
397 { 399 {
398 wiface->setChannel( i ); 400 wiface->setChannel( i );
399 pb->setProgress( i ); 401 pb->setProgress( i );
400 qApp->processEvents(); 402 qApp->processEvents();
401 odebug << "rescanNeighbourhood(): listening on channel " << i << "..." << oendl; 403 odebug << "rescanNeighbourhood(): listening on channel " << i << "..." << oendl;
402 OPacket* p = cap->next( 1000 ); 404 OPacket* p = cap->next( 1000 );
403 if ( !p ) 405 if ( !p )
404 { 406 {
405 odebug << "rescanNeighbourhood(): nothing received on channel " << i << "" << oendl; 407 odebug << "rescanNeighbourhood(): nothing received on channel " << i << "" << oendl;
406 } 408 }
407 else 409 else
408 { 410 {
409 odebug << "rescanNeighbourhood(): TADAA - something came in on channel " << i << "" << oendl; 411 odebug << "rescanNeighbourhood(): TADAA - something came in on channel " << i << "" << oendl;
410 handlePacket( p ); 412 handlePacket( p );
411 } 413 }
412 } 414 }
413 415
414 cap->close(); 416 cap->close();
415 wiface->setMode( "managed" ); // TODO: use previous mode 417 wiface->setMode( "managed" ); // TODO: use previous mode
416 wiface->setPromiscuousMode( false ); 418 wiface->setPromiscuousMode( false );
417 419
418 splash->hide(); 420 splash->hide();
419 delete splash; 421 delete splash;
420 422
421} 423}
422 424
423void WLANImp::handlePacket( OPacket* p ) 425void WLANImp::handlePacket( OPacket* p )
424{ 426{
425 427
426 // check if we received a beacon frame 428 // check if we received a beacon frame
427 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); 429 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) );
428 if ( beacon && beacon->managementType() == "Beacon" ) 430 if ( beacon && beacon->managementType() == "Beacon" )
429 { 431 {
430 432
431 QString type; 433 QString type;
432 if ( beacon->canIBSS() ) 434 if ( beacon->canIBSS() )
433 { 435 {
434 type = "adhoc"; 436 type = "adhoc";
435 } 437 }
436 else if ( beacon->canESS() ) 438 else if ( beacon->canESS() )
437 { 439 {
438 type = "managed"; 440 type = "managed";
439 } 441 }
440 else 442 else
441 { 443 {
442 owarn << "handlePacket(): invalid frame [possibly noise] detected!" << oendl; 444 owarn << "handlePacket(): invalid frame [possibly noise] detected!" << oendl;
443 return; 445 return;
444 } 446 }
445 447
446 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); 448 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
447 QString essid = ssid ? ssid->ID() : QString("<unknown>"); 449 QString essid = ssid ? ssid->ID() : QString("<unknown>");
448 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); 450 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
449 int channel = ds ? ds->channel() : -1; 451 int channel = ds ? ds->channel() : -1;
450 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 452 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
451 displayFoundNetwork( type, channel, essid, header->macAddress2() ); 453 displayFoundNetwork( type, channel, essid, header->macAddress2() );
452 } 454 }
453} 455}
454 456
455 457
456void WLANImp::displayFoundNetwork( const QString& mode, int channel, const QString& ssid, const OMacAddress& mac ) 458void WLANImp::displayFoundNetwork( const QString& mode, int channel, const QString& ssid, const OMacAddress& mac )
457{ 459{
458 460
459 qDebug( "found network: <%s>, chn %d, ssid '%s', mac '%s'", (const char*) mode, channel, 461 qDebug( "found network: <%s>, chn %d, ssid '%s', mac '%s'", (const char*) mode, channel,
460 (const char*) ssid, 462 (const char*) ssid,
461 (const char*) mac.toString() ); 463 (const char*) mac.toString() );
462 464
463 QListViewItemIterator it( netView ); 465 QListViewItemIterator it( netView );
464 while ( it.current() && it.current()->text( col_ssid ) != ssid ) ++it; 466 while ( it.current() && it.current()->text( col_ssid ) != ssid ) ++it;
465 if ( !it.current() ) // ssid didn't show up yet 467 if ( !it.current() ) // ssid didn't show up yet
466 { 468 {
467 QListViewItem* item = new QListViewItem( netView, mode.left( 1 ).upper(), ssid, QString::number( channel ), mac.toString() ); 469 QListViewItem* item = new QListViewItem( netView, mode.left( 1 ).upper(), ssid, QString::number( channel ), mac.toString() );
468 QString name; 470 QString name;
469 name.sprintf( "networksettings/%s", (const char*) mode ); 471 name.sprintf( "networksettings/%s", (const char*) mode );
470 item->setPixmap( col_mode, Resource::loadPixmap( name ) ); 472 item->setPixmap( col_mode, Resource::loadPixmap( name ) );
471 qApp->processEvents(); 473 qApp->processEvents();
472 } 474 }
473 475
474} 476}
475 477
476 478
477void WLANImp::selectNetwork( QListViewItem* item ) 479void WLANImp::selectNetwork( QListViewItem* item )
478{ 480{
479 bool ok; 481 bool ok;
480 if ( item ) 482 if ( item )
481 { 483 {
482 specifyAp->setChecked(true); 484 specifyAp->setChecked(true);
483 macEdit->setText( item->text( col_mac ) ); 485 macEdit->setText( item->text( col_mac ) );
484 specifyChan->setChecked( item->text( col_mode ) == "A" ); 486 specifyChan->setChecked( item->text( col_mode ) == "A" );
485 networkChannel->setValue( item->text( col_chn ).toInt( &ok ) ); 487 networkChannel->setValue( item->text( col_chn ).toInt( &ok ) );
486 essid->setEditText( item->text( col_ssid ) ); 488 essid->setEditText( item->text( col_ssid ) );
487 if ( item->text( col_mode ) == "A" ) 489 if ( item->text( col_mode ) == "A" )
488 mode->setCurrentItem( 3 ); 490 mode->setCurrentItem( 3 );
489 else 491 else
490 mode->setCurrentItem( 2 ); 492 mode->setCurrentItem( 2 );
491 } 493 }
492} 494}
diff --git a/noncore/settings/networksettings/wlan/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp
index 886af10..ba89fa4 100644
--- a/noncore/settings/networksettings/wlan/wlanmodule.cpp
+++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp
@@ -1,255 +1,257 @@
1 1
2#include "wlanmodule.h" 2#include "wlanmodule.h"
3#include "wlanimp2.h" 3#include "wlanimp2.h"
4#include "infoimp.h" 4#include "infoimp.h"
5#include "wextensions.h" 5#include "wextensions.h"
6#include "interfaceinformationimp.h" 6#include "interfaceinformationimp.h"
7 7
8/* OPIE */ 8/* OPIE */
9#include <opie2/odebug.h>
9#include <qpe/qpeapplication.h> 10#include <qpe/qpeapplication.h>
11using namespace Opie::Core;
10 12
11/* QT */ 13/* QT */
12#include <qcheckbox.h> 14#include <qcheckbox.h>
13#include <qcombobox.h> 15#include <qcombobox.h>
14#include <qlabel.h> 16#include <qlabel.h>
15#include <qlineedit.h> 17#include <qlineedit.h>
16#include <qprogressbar.h> 18#include <qprogressbar.h>
17#include <qspinbox.h> 19#include <qspinbox.h>
18#include <qtabwidget.h> 20#include <qtabwidget.h>
19 21
20 22
21/** 23/**
22 * Constructor, find all of the possible interfaces 24 * Constructor, find all of the possible interfaces
23 */ 25 */
24WLANModule::WLANModule() 26WLANModule::WLANModule()
25 : Module(), 27 : Module(),
26 wlanconfigWiget(0) 28 wlanconfigWiget(0)
27{ 29{
28} 30}
29 31
30/** 32/**
31 * Delete any interfaces that we own. 33 * Delete any interfaces that we own.
32 */ 34 */
33WLANModule::~WLANModule(){ 35WLANModule::~WLANModule(){
34 Interface *i; 36 Interface *i;
35 for ( i=list.first(); i != 0; i=list.next() ) 37 for ( i=list.first(); i != 0; i=list.next() )
36 delete i; 38 delete i;
37 39
38} 40}
39 41
40/** 42/**
41 * Change the current profile 43 * Change the current profile
42 */ 44 */
43void WLANModule::setProfile(const QString &newProfile){ 45void WLANModule::setProfile(const QString &newProfile){
44 profile = newProfile; 46 profile = newProfile;
45} 47}
46 48
47/** 49/**
48 * get the icon name for this device. 50 * get the icon name for this device.
49 * @param Interface* can be used in determining the icon. 51 * @param Interface* can be used in determining the icon.
50 * @return QString the icon name (minus .png, .gif etc) 52 * @return QString the icon name (minus .png, .gif etc)
51 */ 53 */
52QString WLANModule::getPixmapName(Interface* ){ 54QString WLANModule::getPixmapName(Interface* ){
53 return "wlan"; 55 return "wlan";
54} 56}
55 57
56/** 58/**
57 * Check to see if the interface i is owned by this module. 59 * Check to see if the interface i is owned by this module.
58 * @param Interface* interface to check against 60 * @param Interface* interface to check against
59 * @return bool true if i is owned by this module, false otherwise. 61 * @return bool true if i is owned by this module, false otherwise.
60 */ 62 */
61bool WLANModule::isOwner(Interface *i){ 63bool WLANModule::isOwner(Interface *i){
62 WExtensions we(i->getInterfaceName()); 64 WExtensions we(i->getInterfaceName());
63 if(!we.doesHaveWirelessExtensions()) 65 if(!we.doesHaveWirelessExtensions())
64 return false; 66 return false;
65 67
66 i->setHardwareName("802.11b"); 68 i->setHardwareName("802.11b");
67 list.append(i); 69 list.append(i);
68 return true; 70 return true;
69} 71}
70 72
71/** 73/**
72 * Create, and return the WLANConfigure Module 74 * Create, and return the WLANConfigure Module
73 * @return QWidget* pointer to this modules configure. 75 * @return QWidget* pointer to this modules configure.
74 */ 76 */
75QWidget *WLANModule::configure(Interface *i){ 77QWidget *WLANModule::configure(Interface *i){
76 WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", i, true, Qt::WDestructiveClose); 78 WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", i, true, Qt::WDestructiveClose);
77 wlanconfig->setProfile(profile); 79 wlanconfig->setProfile(profile);
78 return wlanconfig; 80 return wlanconfig;
79} 81}
80 82
81/** 83/**
82 * Create, and return the Information Module 84 * Create, and return the Information Module
83 * @return QWidget* pointer to this modules info. 85 * @return QWidget* pointer to this modules info.
84 */ 86 */
85QWidget *WLANModule::information(Interface *i){ 87QWidget *WLANModule::information(Interface *i){
86 WExtensions we(i->getInterfaceName()); 88 WExtensions we(i->getInterfaceName());
87 if(!we.doesHaveWirelessExtensions()) 89 if(!we.doesHaveWirelessExtensions())
88 return NULL; 90 return NULL;
89 91
90 return getInfo( i ); 92 return getInfo( i );
91} 93}
92 94
93/** 95/**
94 * Get all active (up or down) interfaces 96 * Get all active (up or down) interfaces
95 * @return QList<Interface> A list of interfaces that exsist that havn't 97 * @return QList<Interface> A list of interfaces that exsist that havn't
96 * been called by isOwner() 98 * been called by isOwner()
97 */ 99 */
98QList<Interface> WLANModule::getInterfaces(){ 100QList<Interface> WLANModule::getInterfaces(){
99 return list; 101 return list;
100} 102}
101 103
102/** 104/**
103 * Attempt to add a new interface as defined by name 105 * Attempt to add a new interface as defined by name
104 * @param name the name of the type of interface that should be created given 106 * @param name the name of the type of interface that should be created given
105 * by possibleNewInterfaces(); 107 * by possibleNewInterfaces();
106 * @return Interface* NULL if it was unable to be created. 108 * @return Interface* NULL if it was unable to be created.
107 */ 109 */
108Interface *WLANModule::addNewInterface(const QString &){ 110Interface *WLANModule::addNewInterface(const QString &){
109 // We can't add a 802.11 interface, either the hardware will be there 111 // We can't add a 802.11 interface, either the hardware will be there
110 // or it wont. 112 // or it wont.
111 return NULL; 113 return NULL;
112} 114}
113 115
114/** 116/**
115 * Attempts to remove the interface, doesn't delete i 117 * Attempts to remove the interface, doesn't delete i
116 * @return bool true if successful, false otherwise. 118 * @return bool true if successful, false otherwise.
117 */ 119 */
118bool WLANModule::remove(Interface*){ 120bool WLANModule::remove(Interface*){
119 // Can't remove a hardware device, you can stop it though. 121 // Can't remove a hardware device, you can stop it though.
120 return false; 122 return false;
121} 123}
122 124
123void WLANModule::receive(const QCString &param, const QByteArray &arg) 125void WLANModule::receive(const QCString &param, const QByteArray &arg)
124{ 126{
125 odebug << "WLANModule::receive "+param << oendl; 127 odebug << "WLANModule::receive "+param << oendl;
126 QStringList params = QStringList::split(",",param); 128 QStringList params = QStringList::split(",",param);
127 int count = params.count(); 129 int count = params.count();
128 odebug << "WLANModule got " << count << " params" << oendl; 130 odebug << "WLANModule got " << count << " params" << oendl;
129 if (count < 2){ 131 if (count < 2){
130 odebug << "Erorr less than 2 parameter" << oendl; 132 odebug << "Erorr less than 2 parameter" << oendl;
131 odebug << "RETURNING" << oendl; 133 odebug << "RETURNING" << oendl;
132 return; 134 return;
133 } 135 }
134 136
135 QDataStream stream(arg,IO_ReadOnly); 137 QDataStream stream(arg,IO_ReadOnly);
136 QString interface; 138 QString interface;
137 QString action; 139 QString action;
138 int countMsgs = 0; 140 int countMsgs = 0;
139 stream >> interface; 141 stream >> interface;
140 odebug << "got count? >" << interface.latin1() << "<" << oendl; 142 odebug << "got count? >" << interface.latin1() << "<" << oendl;
141 if (interface == "count"){ 143 if (interface == "count"){
142 odebug << "got count" << oendl; 144 odebug << "got count" << oendl;
143 stream >> action; 145 stream >> action;
144 odebug << "Got count num >" << action.latin1() << "<" << oendl; 146 odebug << "Got count num >" << action.latin1() << "<" << oendl;
145 countMsgs = action.toInt(); 147 countMsgs = action.toInt();
146 } 148 }
147 149
148 QDialog *toShow; 150 QDialog *toShow;
149 //while (! stream.atEnd() ){ 151 //while (! stream.atEnd() ){
150 for (int i = 0; i < countMsgs; i++){ 152 for (int i = 0; i < countMsgs; i++){
151 odebug << "start stream " << i << "/" << countMsgs << "" << oendl; 153 odebug << "start stream " << i << "/" << countMsgs << "" << oendl;
152 if (stream.atEnd()){ 154 if (stream.atEnd()){
153 odebug << "end of stream" << oendl; 155 odebug << "end of stream" << oendl;
154 return; 156 return;
155 } 157 }
156 stream >> interface; 158 stream >> interface;
157 odebug << "got iface" << oendl; 159 odebug << "got iface" << oendl;
158 stream >> action; 160 stream >> action;
159 odebug << "WLANModule got interface " << interface.latin1() << " and acion " << action.latin1() << "" << oendl; 161 odebug << "WLANModule got interface " << interface.latin1() << " and acion " << action.latin1() << "" << oendl;
160 // find interfaces 162 // find interfaces
161 Interface *ifa=0; 163 Interface *ifa=0;
162 for ( Interface *i=list.first(); i != 0; i=list.next() ){ 164 for ( Interface *i=list.first(); i != 0; i=list.next() ){
163 if (i->getInterfaceName() == interface){ 165 if (i->getInterfaceName() == interface){
164 odebug << "WLANModule found interface " << interface.latin1() << "" << oendl; 166 odebug << "WLANModule found interface " << interface.latin1() << "" << oendl;
165 ifa = i; 167 ifa = i;
166 } 168 }
167 } 169 }
168 170
169 if (ifa == 0){ 171 if (ifa == 0){
170 odebug << "WLANModule Did not find " << interface.latin1() << "" << oendl; 172 odebug << "WLANModule Did not find " << interface.latin1() << "" << oendl;
171 odebug << "skipping" << oendl; 173 odebug << "skipping" << oendl;
172 count = 0; 174 count = 0;
173 } 175 }
174 176
175 if (count == 2){ 177 if (count == 2){
176 // those should call the interface directly 178 // those should call the interface directly
177 QWidget *info = getInfo( ifa ); 179 QWidget *info = getInfo( ifa );
178 QPEApplication::showWidget( info ); 180 QPEApplication::showWidget( info );
179 181
180 if ( action.contains("start" ) ){ 182 if ( action.contains("start" ) ){
181 ifa->start(); 183 ifa->start();
182 } else if ( action.contains("restart" ) ){ 184 } else if ( action.contains("restart" ) ){
183 ifa->restart(); 185 ifa->restart();
184 } else if ( action.contains("stop" ) ){ 186 } else if ( action.contains("stop" ) ){
185 ifa->stop(); 187 ifa->stop();
186 }else if ( action.contains("refresh" ) ){ 188 }else if ( action.contains("refresh" ) ){
187 ifa->refresh(); 189 ifa->refresh();
188 } 190 }
189 }else if (count == 3){ 191 }else if (count == 3){
190 QString value; 192 QString value;
191 if (!wlanconfigWiget){ 193 if (!wlanconfigWiget){
192 //FIXME: what if it got closed meanwhile? 194 //FIXME: what if it got closed meanwhile?
193 wlanconfigWiget = (WLANImp*) configure(ifa); 195 wlanconfigWiget = (WLANImp*) configure(ifa);
194 toShow = (QDialog*) wlanconfigWiget; 196 toShow = (QDialog*) wlanconfigWiget;
195 } 197 }
196 QPEApplication::showWidget( wlanconfigWiget ); 198 QPEApplication::showWidget( wlanconfigWiget );
197 stream >> value; 199 stream >> value;
198 odebug << "WLANModule (build 4) is setting " << action.latin1() << " of " << interface.latin1() << " to " << value.latin1() << "" << oendl; 200 odebug << "WLANModule (build 4) is setting " << action.latin1() << " of " << interface.latin1() << " to " << value.latin1() << "" << oendl;
199 if (value.isEmpty()){ 201 if (value.isEmpty()){
200 odebug << "value is empty!!!\nreturning" << oendl; 202 odebug << "value is empty!!!\nreturning" << oendl;
201 return; 203 return;
202 } 204 }
203 if ( action.contains("ESSID") ){ 205 if ( action.contains("ESSID") ){
204 QComboBox *combo = wlanconfigWiget->essid; 206 QComboBox *combo = wlanconfigWiget->essid;
205 bool found = false; 207 bool found = false;
206 for ( int i = 0; i < combo->count(); i++) 208 for ( int i = 0; i < combo->count(); i++)
207 if ( combo->text( i ) == value ){ 209 if ( combo->text( i ) == value ){
208 combo->setCurrentItem( i ); 210 combo->setCurrentItem( i );
209 found = true; 211 found = true;
210 } 212 }
211 if (!found) combo->insertItem( value, 0 ); 213 if (!found) combo->insertItem( value, 0 );
212 }else if ( action.contains("Mode") ){ 214 }else if ( action.contains("Mode") ){
213 QComboBox *combo = wlanconfigWiget->mode; 215 QComboBox *combo = wlanconfigWiget->mode;
214 for ( int i = 0; i < combo->count(); i++) 216 for ( int i = 0; i < combo->count(); i++)
215 if ( combo->text( i ) == value ){ 217 if ( combo->text( i ) == value ){
216 combo->setCurrentItem( i ); 218 combo->setCurrentItem( i );
217 } 219 }
218 220
219 }else if (action.contains("Channel")){ 221 }else if (action.contains("Channel")){
220 bool ok; 222 bool ok;
221 odebug << "converting channel" << oendl; 223 odebug << "converting channel" << oendl;
222 int chan = value.toInt( &ok ); 224 int chan = value.toInt( &ok );
223 if (ok){ 225 if (ok){
224 odebug << "ok setting channel" << oendl; 226 odebug << "ok setting channel" << oendl;
225 wlanconfigWiget->specifyChan->setChecked( true ); 227 wlanconfigWiget->specifyChan->setChecked( true );
226 wlanconfigWiget->networkChannel->setValue( chan ); 228 wlanconfigWiget->networkChannel->setValue( chan );
227 } 229 }
228 }else if (action.contains("MacAddr")){ 230 }else if (action.contains("MacAddr")){
229 wlanconfigWiget->specifyAp->setChecked( true ); 231 wlanconfigWiget->specifyAp->setChecked( true );
230 wlanconfigWiget->macEdit->setText( value ); 232 wlanconfigWiget->macEdit->setText( value );
231 }else 233 }else
232 odebug << "wlan plugin has no clue" << oendl; 234 odebug << "wlan plugin has no clue" << oendl;
233 } 235 }
234 odebug << "next stream" << oendl; 236 odebug << "next stream" << oendl;
235 }// while stream 237 }// while stream
236 odebug << "end of stream" << oendl; 238 odebug << "end of stream" << oendl;
237 if (toShow) toShow->exec(); 239 if (toShow) toShow->exec();
238 odebug << "returning" << oendl; 240 odebug << "returning" << oendl;
239} 241}
240 242
241QWidget *WLANModule::getInfo( Interface *i) 243QWidget *WLANModule::getInfo( Interface *i)
242{ 244{
243 odebug << "WLANModule::getInfo start" << oendl; 245 odebug << "WLANModule::getInfo start" << oendl;
244 WlanInfoImp *info = new WlanInfoImp(0, i->getInterfaceName(), Qt::WDestructiveClose); 246 WlanInfoImp *info = new WlanInfoImp(0, i->getInterfaceName(), Qt::WDestructiveClose);
245 InterfaceInformationImp *information = new InterfaceInformationImp(info->tabWidget, "InterfaceSetupImp", i); 247 InterfaceInformationImp *information = new InterfaceInformationImp(info->tabWidget, "InterfaceSetupImp", i);
246 info->tabWidget->insertTab(information, "TCP/IP", 0); 248 info->tabWidget->insertTab(information, "TCP/IP", 0);
247 info->tabWidget->setCurrentPage( 0 ); 249 info->tabWidget->setCurrentPage( 0 );
248 info->tabWidget->showPage( information ); 250 info->tabWidget->showPage( information );
249 if (info->tabWidget->currentPage() == information ) odebug << "infotab OK" << oendl; 251 if (info->tabWidget->currentPage() == information ) odebug << "infotab OK" << oendl;
250 else odebug << "infotab NOT OK" << oendl; 252 else odebug << "infotab NOT OK" << oendl;
251 odebug << "current idx " << info->tabWidget->currentPageIndex() << "" << oendl; 253 odebug << "current idx " << info->tabWidget->currentPageIndex() << "" << oendl;
252 odebug << "WLANModule::getInfo return" << oendl; 254 odebug << "WLANModule::getInfo return" << oendl;
253 return info; 255 return info;
254} 256}
255 257