summaryrefslogtreecommitdiff
authorzecke <zecke>2004-09-10 11:16:54 (UTC)
committer zecke <zecke>2004-09-10 11:16:54 (UTC)
commit59dbb076579e0387f960525b415511946eb83b17 (patch) (unidiff)
treedc8caeebf7e5a1968a399838b53cb09a1537d9ec
parentb8baf551919868737c6f56a05e6efa1bad4d97ac (diff)
downloadopie-59dbb076579e0387f960525b415511946eb83b17.zip
opie-59dbb076579e0387f960525b415511946eb83b17.tar.gz
opie-59dbb076579e0387f960525b415511946eb83b17.tar.bz2
Fix the issues the compilers bothers
remove unused parameters, give return values on return
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/interfaces/interfacesetupimp.cpp16
-rw-r--r--noncore/settings/networksettings/mainwindow/addconnectionimp.cpp8
-rw-r--r--noncore/settings/networksettings/ppp/connect.cpp13
-rw-r--r--noncore/settings/networksettings/ppp/devices.cpp6
-rw-r--r--noncore/settings/networksettings/ppp/edit.cpp2
-rw-r--r--noncore/settings/networksettings/ppp/interfaceinformationppp.cpp4
-rw-r--r--noncore/settings/networksettings/ppp/pppmodule.cpp23
-rw-r--r--noncore/settings/networksettings/ppp/pppmodule.h2
-rw-r--r--noncore/settings/networksettings/wlan/keyedit.cpp4
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp2.cpp1
10 files changed, 40 insertions, 39 deletions
diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
index 8498759..62b1b7a 100644
--- a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
+++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
@@ -1,209 +1,209 @@
1#include "interfacesetupimp.h" 1#include "interfacesetupimp.h"
2#include "interface.h" 2#include "interface.h"
3 3
4#include <qcheckbox.h> 4#include <qcheckbox.h>
5#include <qlineedit.h> 5#include <qlineedit.h>
6#include <qspinbox.h> 6#include <qspinbox.h>
7#include <qgroupbox.h> 7#include <qgroupbox.h>
8#include <qlabel.h> 8#include <qlabel.h>
9 9
10#include <qmessagebox.h> 10#include <qmessagebox.h>
11 11
12#include <opie2/oprocess.h> 12#include <opie2/oprocess.h>
13 13
14#ifdef QWS 14#ifdef QWS
15#include <opie2/owait.h> 15#include <opie2/owait.h>
16#include <opie2/odebug.h> 16#include <opie2/odebug.h>
17#include <qpe/global.h> 17#include <qpe/global.h>
18#include <qapplication.h> 18#include <qapplication.h>
19#endif 19#endif
20 20
21#define DNSSCRIPT "changedns" 21#define DNSSCRIPT "changedns"
22 22
23/** 23/**
24 * Constuctor. Set up the connection. A profile must be set. 24 * Constuctor. Set up the connection. A profile must be set.
25 */ 25 */
26using namespace Opie::Ui; 26using namespace Opie::Ui;
27using namespace Opie::Core; 27using namespace Opie::Core;
28InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, Interfaces *j, WFlags fl) : InterfaceSetup(parent, name, fl), interface(i), interfaces(j), delInterfaces(false){ 28InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, Interfaces *j, WFlags fl) : InterfaceSetup(parent, name, fl), interfaces(j), interface(i), delInterfaces(false){
29 if (j == 0) { 29 if (j == 0) {
30 delInterfaces = true; 30 delInterfaces = true;
31 interfaces = new Interfaces; 31 interfaces = new Interfaces;
32 } 32 }
33} 33}
34 34
35/** 35/**
36 * Destructor 36 * Destructor
37 */ 37 */
38InterfaceSetupImp::~InterfaceSetupImp(){ 38InterfaceSetupImp::~InterfaceSetupImp(){
39 if(delInterfaces) { 39 if(delInterfaces) {
40 delete interfaces; 40 delete interfaces;
41 } 41 }
42} 42}
43 43
44/** 44/**
45 * Save the current settings, then write out the interfaces file and close. 45 * Save the current settings, then write out the interfaces file and close.
46 */ 46 */
47bool InterfaceSetupImp::saveChanges(){ 47bool InterfaceSetupImp::saveChanges(){
48 bool error; 48 bool error;
49 QString iface = interfaces->getInterfaceName(error); 49 QString iface = interfaces->getInterfaceName(error);
50 odebug << "InterfaceSetupImp::saveChanges saves interface " << iface.latin1() << "" << oendl; 50 odebug << "InterfaceSetupImp::saveChanges saves interface " << iface.latin1() << "" << oendl;
51 if(!saveSettings()) 51 if(!saveSettings())
52 return false; 52 return false;
53 53
54 interfaces->write(); 54 interfaces->write();
55 55
56 if (interface->getStatus()) { 56 if (interface->getStatus()) {
57 QString ifup; 57 QString ifup;
58 ifup += "ifdown "; 58 ifup += "ifdown ";
59 ifup += iface; 59 ifup += iface;
60 ifup += "; ifup "; 60 ifup += "; ifup ";
61 ifup += iface; 61 ifup += iface;
62 ifup += ";"; 62 ifup += ";";
63 63
64 OProcess restart; 64 OProcess restart;
65 restart << "sh"; 65 restart << "sh";
66 restart << "-c"; 66 restart << "-c";
67 restart << ifup; 67 restart << ifup;
68 68
69 OWait *owait = new OWait(); 69 OWait *owait = new OWait();
70 Global::statusMessage( tr( "Restarting interface" ) ); 70 Global::statusMessage( tr( "Restarting interface" ) );
71 71
72 owait->show(); 72 owait->show();
73 qApp->processEvents(); 73 qApp->processEvents();
74 74
75 if (!restart.start(OProcess::Block, OProcess::NoCommunication) ) { 75 if (!restart.start(OProcess::Block, OProcess::NoCommunication) ) {
76 owarn << "unstable to spawn ifdown/ifup" << oendl; 76 owarn << "unstable to spawn ifdown/ifup" << oendl;
77 } 77 }
78 78
79 owait->hide(); 79 owait->hide();
80 delete owait; 80 delete owait;
81 81
82 interface->refresh(); 82 interface->refresh();
83 } 83 }
84 return true; 84 return true;
85} 85}
86 86
87/** 87/**
88 * Save the settings for the current Interface. 88 * Save the settings for the current Interface.
89 * @return bool true if successful, false otherwise 89 * @return bool true if successful, false otherwise
90 */ 90 */
91bool InterfaceSetupImp::saveSettings(){ 91bool InterfaceSetupImp::saveSettings(){
92 // eh can't really do anything about it other then return. :-D 92 // eh can't really do anything about it other then return. :-D
93 if(!interfaces->isInterfaceSet()) 93 if(!interfaces->isInterfaceSet())
94 return true; 94 return true;
95 95
96 bool error = false; 96 bool error = false;
97 // Loopback case 97 // Loopback case
98 if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ 98 if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){
99 interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); 99 interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked());
100 return true; 100 return true;
101 } 101 }
102 102
103 if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){ 103 if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){
104 QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", QMessageBox::Ok); 104 QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", QMessageBox::Ok);
105 return false; 105 return false;
106 } 106 }
107 // DHCP 107 // DHCP
108 if(dhcpCheckBox->isChecked()) { 108 if(dhcpCheckBox->isChecked()) {
109 interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); 109 interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP);
110 interfaces->removeInterfaceOption("address"); 110 interfaces->removeInterfaceOption("address");
111 interfaces->removeInterfaceOption("netmask"); 111 interfaces->removeInterfaceOption("netmask");
112 interfaces->removeInterfaceOption("gateway"); 112 interfaces->removeInterfaceOption("gateway");
113 interfaces->removeInterfaceOption("up "DNSSCRIPT" -a "); 113 interfaces->removeInterfaceOption("up "DNSSCRIPT" -a ");
114 interfaces->removeInterfaceOption("down "DNSSCRIPT" -r "); 114 interfaces->removeInterfaceOption("down "DNSSCRIPT" -r ");
115 } else{ 115 } else{
116 interfaces->setInterfaceMethod("static"); 116 interfaces->setInterfaceMethod("static");
117 interfaces->setInterfaceOption("address", ipAddressEdit->text()); 117 interfaces->setInterfaceOption("address", ipAddressEdit->text());
118 interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); 118 interfaces->setInterfaceOption("netmask", subnetMaskEdit->text());
119 interfaces->setInterfaceOption("gateway", gatewayEdit->text()); 119 interfaces->setInterfaceOption("gateway", gatewayEdit->text());
120 if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){ 120 if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){
121 QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); 121 QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text();
122 interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); 122 interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns);
123 interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); 123 interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns);
124 }else{ 124 }else{
125 interfaces->removeInterfaceOption("up "DNSSCRIPT" -a "); 125 interfaces->removeInterfaceOption("up "DNSSCRIPT" -a ");
126 interfaces->removeInterfaceOption("down "DNSSCRIPT" -r"); 126 interfaces->removeInterfaceOption("down "DNSSCRIPT" -r");
127 } 127 }
128 } 128 }
129 129
130 // IP Information 130 // IP Information
131 interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); 131 interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked());
132 return true; 132 return true;
133} 133}
134 134
135/** 135/**
136 * The Profile has changed. 136 * The Profile has changed.
137 * @param QString profile the new profile. 137 * @param QString profile the new profile.
138 */ 138 */
139void InterfaceSetupImp::setProfile(const QString &profile){ 139void InterfaceSetupImp::setProfile(const QString &profile){
140 /* 140 /*
141 bool error = false; 141 bool error = false;
142 if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ 142 if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){
143 staticGroupBox->hide(); 143 staticGroupBox->hide();
144 dhcpCheckBox->hide(); 144 dhcpCheckBox->hide();
145 leaseTime->hide(); 145 leaseTime->hide();
146 leaseHoursLabel->hide(); 146 leaseHoursLabel->hide();
147 } 147 }
148 */ 148 */
149 149
150 QString newInterfaceName = interface->getInterfaceName(); 150 QString newInterfaceName = interface->getInterfaceName();
151 if(profile.length() > 0) 151 if(profile.length() > 0)
152 newInterfaceName += "_" + profile; 152 newInterfaceName += "_" + profile;
153 // See if we have to make a interface. 153 // See if we have to make a interface.
154 if(!interfaces->setInterface(newInterfaceName)){ 154 if(!interfaces->setInterface(newInterfaceName)){
155 // Add making for this new interface if need too 155 // Add making for this new interface if need too
156 if(profile != ""){ 156 if(profile != ""){
157 interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); 157 interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName);
158 if(!interfaces->setMapping(interface->getInterfaceName())){ 158 if(!interfaces->setMapping(interface->getInterfaceName())){
159 interfaces->addMapping(interface->getInterfaceName()); 159 interfaces->addMapping(interface->getInterfaceName());
160 if(!interfaces->setMapping(interface->getInterfaceName())){ 160 if(!interfaces->setMapping(interface->getInterfaceName())){
161 odebug << "InterfaceSetupImp: Added Mapping, but still can't setInterface." << oendl; 161 odebug << "InterfaceSetupImp: Added Mapping, but still can't setInterface." << oendl;
162 return; 162 return;
163 } 163 }
164 } 164 }
165 interfaces->setMap("map", newInterfaceName); 165 interfaces->setMap("map", newInterfaceName);
166 interfaces->setScript("getprofile.sh"); 166 interfaces->setScript("getprofile.sh");
167 } 167 }
168 else{ 168 else{
169 interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); 169 interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP);
170 if(!interfaces->setInterface(newInterfaceName)){ 170 if(!interfaces->setInterface(newInterfaceName)){
171 odebug << "InterfaceSetupImp: Added interface, but still can't setInterface." << oendl; 171 odebug << "InterfaceSetupImp: Added interface, but still can't setInterface." << oendl;
172 return; 172 return;
173 } 173 }
174 } 174 }
175 } 175 }
176 176
177 // We must have a valid interface to get this far so read some settings. 177 // We must have a valid interface to get this far so read some settings.
178 178
179 // DHCP 179 // DHCP
180 bool error = false; 180 bool error = false;
181 if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) 181 if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP)
182 dhcpCheckBox->setChecked(true); 182 dhcpCheckBox->setChecked(true);
183 else 183 else
184 dhcpCheckBox->setChecked(false); 184 dhcpCheckBox->setChecked(false);
185 185
186 // IP Information 186 // IP Information
187 autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); 187 autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName()));
188 QString dns = interfaces->getInterfaceOption("up "DNSSCRIPT" -a", error); 188 QString dns = interfaces->getInterfaceOption("up "DNSSCRIPT" -a", error);
189 odebug << "dns >" << dns.latin1() << "<" << oendl; 189 odebug << "dns >" << dns.latin1() << "<" << oendl;
190 if(dns.contains(" ")){ 190 if(dns.contains(" ")){
191 firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); 191 firstDNSLineEdit->setText(dns.mid(0, dns.find(" ")));
192 secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); 192 secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length()));
193 }else firstDNSLineEdit->setText(dns); 193 }else firstDNSLineEdit->setText(dns);
194 194
195 ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); 195 ipAddressEdit->setText(interfaces->getInterfaceOption("address", error));
196 subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); 196 subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error));
197 if (subnetMaskEdit->text().isEmpty()) 197 if (subnetMaskEdit->text().isEmpty())
198 subnetMaskEdit->setText( "255.255.255.0" ); 198 subnetMaskEdit->setText( "255.255.255.0" );
199 gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); 199 gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error));
200 200
201 201
202 202
203 owarn << "InterfaceSetupImp::setProfile(" << profile.latin1() << ")\n" << oendl; 203 owarn << "InterfaceSetupImp::setProfile(" << profile.latin1() << ")\n" << oendl;
204 owarn << "InterfaceSetupImp::setProfile: iface is " << interfaces->getInterfaceName(error).latin1() << "\n" << oendl; 204 owarn << "InterfaceSetupImp::setProfile: iface is " << interfaces->getInterfaceName(error).latin1() << "\n" << oendl;
205 205
206} 206}
207 207
208// interfacesetup.cpp 208// interfacesetup.cpp
209 209
diff --git a/noncore/settings/networksettings/mainwindow/addconnectionimp.cpp b/noncore/settings/networksettings/mainwindow/addconnectionimp.cpp
index f18d8d1..84f1cf6 100644
--- a/noncore/settings/networksettings/mainwindow/addconnectionimp.cpp
+++ b/noncore/settings/networksettings/mainwindow/addconnectionimp.cpp
@@ -1,41 +1,41 @@
1#include "addconnectionimp.h" 1#include "addconnectionimp.h"
2#include <qlistview.h> 2#include <qlistview.h>
3#if QT_VERSION < 300 3#if QT_VERSION < 300
4#include <qlist.h> 4#include <qlist.h>
5#else 5#else
6#include <qptrlist.h> 6#include <qptrlist.h>
7#endif 7#endif
8#include <qlabel.h> 8#include <qlabel.h>
9#include <qheader.h> 9#include <qheader.h>
10 10
11/** 11/**
12 * Constructor 12 * Constructor
13 */ 13 */
14AddConnectionImp::AddConnectionImp(QWidget *parent, const char *name, WFlags f):AddConnection(parent, name, f){ 14AddConnectionImp::AddConnectionImp(QWidget *parent, const char *name, WFlags f):AddConnection(parent, name, f){
15 connect(registeredServicesList, SIGNAL(selectionChanged()), this, SLOT(changed())); 15 connect(registeredServicesList, SIGNAL(selectionChanged()), this, SLOT(changed()));
16 registeredServicesList->header()->hide(); 16 registeredServicesList->header()->hide();
17}; 17};
18 18
19/** 19/**
20 * The current item changed, update the discription. 20 * The current item changed, update the discription.
21 */ 21 */
22void AddConnectionImp::changed(){ 22void AddConnectionImp::changed(){
23 QListViewItem *item = registeredServicesList->currentItem(); 23 QListViewItem *item = registeredServicesList->currentItem();
24 if(item) 24 if(item)
25 help->setText(list[item->text(0)]); 25 help->setText(list[item->text(0)]);
26} 26}
27 27
28/** 28/**
29 * Save a copy of newList for the discriptions and append them all to the view 29 * Save a copy of newList for the discriptions and append them all to the view
30 * @param newList the new list of possible interfaces 30 * @param newList the new list of possible interfaces
31 */ 31 */
32void AddConnectionImp::addConnections(const QMap<QString, QString> &newList){ 32void AddConnectionImp::addConnections(const QMap<QString, QString> &newList){
33 list = newList; 33 list = newList;
34 QMap<QString, QString>::Iterator it; 34 QMap<QString, QString>::Iterator it;
35 for( it = list.begin(); it != list.end(); ++it ) 35 for( it = list.begin(); it != list.end(); ++it )
36 QListViewItem *item = new QListViewItem(registeredServicesList, it.key()); 36 (void)new QListViewItem(registeredServicesList, it.key());
37 registeredServicesList->setCurrentItem(registeredServicesList->firstChild()); 37 registeredServicesList->setCurrentItem(registeredServicesList->firstChild());
38} 38}
39 39
40// addserviceimp.cpp 40// addserviceimp.cpp
41 41
diff --git a/noncore/settings/networksettings/ppp/connect.cpp b/noncore/settings/networksettings/ppp/connect.cpp
index 24d33f4..128877a 100644
--- a/noncore/settings/networksettings/ppp/connect.cpp
+++ b/noncore/settings/networksettings/ppp/connect.cpp
@@ -1,1467 +1,1468 @@
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/* OPIE */ 27/* OPIE */
28#include <opie2/odebug.h> 28#include <opie2/odebug.h>
29using namespace Opie::Core; 29using namespace Opie::Core;
30 30
31/* QT */ 31/* QT */
32#include <qlayout.h> 32#include <qlayout.h>
33#include <qregexp.h> 33#include <qregexp.h>
34#include <qapplication.h> 34#include <qapplication.h>
35#include <qmessagebox.h> 35#include <qmessagebox.h>
36#include <qpushbutton.h> 36#include <qpushbutton.h>
37 37
38/* STD */ 38/* STD */
39#include <unistd.h> 39#include <unistd.h>
40#include <stdlib.h> 40#include <stdlib.h>
41#include <string.h> 41#include <string.h>
42#include <fcntl.h> 42#include <fcntl.h>
43#include <netdb.h> 43#include <netdb.h>
44#include <sys/types.h> 44#include <sys/types.h>
45#include <sys/socket.h> 45#include <sys/socket.h>
46#include <arpa/inet.h> 46#include <arpa/inet.h>
47#include <netinet/in.h> 47#include <netinet/in.h>
48#include <sys/ioctl.h> 48#include <sys/ioctl.h>
49#include <assert.h> 49#include <assert.h>
50 50
51#ifdef _XPG4_2 51#ifdef _XPG4_2
52 #define __xnet_connectconnect 52 #define __xnet_connectconnect
53#endif 53#endif
54 54
55#include <errno.h> 55#include <errno.h>
56 56
57#ifdef HAVE_SYS_PARAM_H 57#ifdef HAVE_SYS_PARAM_H
58#include <sys/param.h> 58#include <sys/param.h>
59#endif 59#endif
60 60
61#ifdef __linux__ 61#ifdef __linux__
62#include "runtests.h" 62#include "runtests.h"
63#endif 63#endif
64 64
65#include "auth.h" 65#include "auth.h"
66#include "connect.h" 66#include "connect.h"
67//#include "docking.h" 67//#include "docking.h"
68#include "interfaceppp.h" 68#include "interfaceppp.h"
69#include "modem.h" 69#include "modem.h"
70#include "kpppconfig.h" 70#include "kpppconfig.h"
71#include "pppdata.h" 71#include "pppdata.h"
72#include "kpppwidget.h" 72#include "kpppwidget.h"
73//#include "requester.h" 73//#include "requester.h"
74//#include "utils.h" 74//#include "utils.h"
75#define execute_command system 75#define execute_command system
76 76
77QString old_hostname; 77QString old_hostname;
78bool modified_hostname; 78bool modified_hostname;
79 79
80 80
81ConnectWidget::ConnectWidget(InterfacePPP *ifp, QWidget *parent, const char *name) 81ConnectWidget::ConnectWidget(InterfacePPP *ifp, QWidget *parent, const char *name)
82 : QWidget(parent, name), 82 : QWidget(parent, name),
83 myreadbuffer(""), 83 myreadbuffer(""),
84 main_timer_ID(0), 84 main_timer_ID(0),
85 vmain(0), 85 vmain(0),
86 substate(-1), 86 substate(-1),
87 scriptindex(0), 87 scriptindex(0),
88 loopnest(0), 88 loopnest(0),
89 loopend(false), 89 loopend(false),
90 semaphore(false), 90 semaphore(false),
91 expecting(false), 91 expecting(false),
92 readbuffer(""), 92 readbuffer(""),
93 scanvar(""), 93 scanvar(""),
94 scanning(false), 94 scanning(false),
95 pausing(false), 95 pausing(false),
96 dialnumber(0), 96 dialnumber(0),
97 _ifaceppp(ifp) 97 _ifaceppp(ifp)
98{ 98{
99 modified_hostname = false; 99 modified_hostname = false;
100 100
101 QVBoxLayout *tl = new QVBoxLayout(this, 8, 10); 101 QVBoxLayout *tl = new QVBoxLayout(this, 8, 10);
102 QString tit = QObject::tr("Connecting to: "); 102 QString tit = QObject::tr("Connecting to: ");
103 setCaption(tit); 103 setCaption(tit);
104 104
105 QHBoxLayout *l0 = new QHBoxLayout(10); 105 QHBoxLayout *l0 = new QHBoxLayout(10);
106 tl->addLayout(l0); 106 tl->addLayout(l0);
107 l0->addSpacing(10); 107 l0->addSpacing(10);
108 messg = new QLabel(this, "messg"); 108 messg = new QLabel(this, "messg");
109 messg->setFrameStyle(QFrame::Panel|QFrame::Sunken); 109 messg->setFrameStyle(QFrame::Panel|QFrame::Sunken);
110 messg->setAlignment(AlignCenter); 110 messg->setAlignment(AlignCenter);
111 messg->setText(QObject::tr("Unable to create modem lock file.")); 111 messg->setText(QObject::tr("Unable to create modem lock file."));
112 messg->setMinimumHeight(messg->sizeHint().height() + 5); 112 messg->setMinimumHeight(messg->sizeHint().height() + 5);
113// int messw = (messg->sizeHint().width() * 12) / 10; 113// int messw = (messg->sizeHint().width() * 12) / 10;
114// messw = QMAX(messw,280); 114// messw = QMAX(messw,280);
115// messg->setMinimumWidth(messw); 115// messg->setMinimumWidth(messw);
116 if (_ifaceppp->getStatus()) 116 if (_ifaceppp->getStatus())
117 messg->setText(QObject::tr("Online")); 117 messg->setText(QObject::tr("Online"));
118 else 118 else
119 messg->setText(QObject::tr("Offline")); 119 messg->setText(QObject::tr("Offline"));
120 l0->addSpacing(10); 120 l0->addSpacing(10);
121 l0->addWidget(messg); 121 l0->addWidget(messg);
122 l0->addSpacing(10); 122 l0->addSpacing(10);
123 123
124 QHBoxLayout *l1 = new QHBoxLayout(10); 124 QHBoxLayout *l1 = new QHBoxLayout(10);
125 tl->addLayout(l1); 125 tl->addLayout(l1);
126 l1->addStretch(1); 126 l1->addStretch(1);
127 127
128 debug = new QPushButton(QObject::tr("Log"), this); 128 debug = new QPushButton(QObject::tr("Log"), this);
129 debug->setToggleButton(true); 129 debug->setToggleButton(true);
130 debug->setEnabled( false ); // FIXME: disable the log button 130 debug->setEnabled( false ); // FIXME: disable the log button
131 connect(debug, SIGNAL(clicked()), SIGNAL(toggleDebugWindow())); 131 connect(debug, SIGNAL(clicked()), SIGNAL(toggleDebugWindow()));
132 132
133 cancel = new QPushButton(QObject::tr("Cancel"), this); 133 cancel = new QPushButton(QObject::tr("Cancel"), this);
134 cancel->setFocus(); 134 cancel->setFocus();
135 connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton())); 135 connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton()));
136 136
137// int maxw = QMAX(cancel->sizeHint().width(), 137// int maxw = QMAX(cancel->sizeHint().width(),
138 // debug->sizeHint().width()); 138 // debug->sizeHint().width());
139// maxw = QMAX(maxw,65); 139// maxw = QMAX(maxw,65);
140// debug->setFixedWidth(maxw); 140// debug->setFixedWidth(maxw);
141// cancel->setFixedWidth(maxw); 141// cancel->setFixedWidth(maxw);
142 l1->addWidget(debug); 142 l1->addWidget(debug);
143 l1->addWidget(cancel); 143 l1->addWidget(cancel);
144 144
145// setFixedSize(sizeHint()); 145// setFixedSize(sizeHint());
146 146
147 pausetimer = new QTimer(this); 147 pausetimer = new QTimer(this);
148 connect(pausetimer, SIGNAL(timeout()), SLOT(pause())); 148 connect(pausetimer, SIGNAL(timeout()), SLOT(pause()));
149 149
150 qApp->processEvents(); 150 qApp->processEvents();
151 151
152 timeout_timer = new QTimer(this); 152 timeout_timer = new QTimer(this);
153 connect(timeout_timer, SIGNAL(timeout()), SLOT(script_timed_out())); 153 connect(timeout_timer, SIGNAL(timeout()), SLOT(script_timed_out()));
154 154
155 inittimer = new QTimer(this); 155 inittimer = new QTimer(this);
156 connect(inittimer, SIGNAL(timeout()), SLOT(init())); 156 connect(inittimer, SIGNAL(timeout()), SLOT(init()));
157 157
158 if_timeout_timer = new QTimer(this); 158 if_timeout_timer = new QTimer(this);
159 connect(if_timeout_timer, SIGNAL(timeout()), SLOT(if_waiting_timed_out())); 159 connect(if_timeout_timer, SIGNAL(timeout()), SLOT(if_waiting_timed_out()));
160 160
161 connect(this,SIGNAL(if_waiting_signal()),this,SLOT(if_waiting_slot())); 161 connect(this,SIGNAL(if_waiting_signal()),this,SLOT(if_waiting_slot()));
162 162
163 prompt = new PWEntry( this, "pw" ); 163 prompt = new PWEntry( this, "pw" );
164 if_timer = new QTimer(this); 164 if_timer = new QTimer(this);
165 connect(if_timer,SIGNAL(timeout()), SLOT(if_waiting_slot())); 165 connect(if_timer,SIGNAL(timeout()), SLOT(if_waiting_slot()));
166} 166}
167 167
168 168
169ConnectWidget::~ConnectWidget() { 169ConnectWidget::~ConnectWidget() {
170} 170}
171 171
172 172
173void ConnectWidget::preinit() { 173void ConnectWidget::preinit() {
174 // this is all just to keep the GUI nice and snappy .... 174 // this is all just to keep the GUI nice and snappy ....
175 // you have to see to believe ... 175 // you have to see to believe ...
176 messg->setText(QObject::tr("Looking for modem...")); 176 messg->setText(QObject::tr("Looking for modem..."));
177 inittimer->start(100); 177 inittimer->start(100);
178} 178}
179 179
180 180
181void ConnectWidget::init() { 181void ConnectWidget::init() {
182 _ifaceppp->data()->setpppdError(0); 182 _ifaceppp->data()->setpppdError(0);
183 inittimer->stop(); 183 inittimer->stop();
184 vmain = 0; 184 vmain = 0;
185 substate = -1; 185 substate = -1;
186 expecting = false; 186 expecting = false;
187 pausing = false; 187 pausing = false;
188 scriptindex = 0; 188 scriptindex = 0;
189 myreadbuffer = ""; 189 myreadbuffer = "";
190 scanning = false; 190 scanning = false;
191 scanvar = ""; 191 scanvar = "";
192 firstrunID = true; 192 firstrunID = true;
193 firstrunPW = true; 193 firstrunPW = true;
194// stats->totalbytes = 0; 194// stats->totalbytes = 0;
195 dialnumber = 0; 195 dialnumber = 0;
196 196
197// p_kppp->con_speed = ""; 197// p_kppp->con_speed = "";
198 198
199// p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || _ifaceppp->data()->quit_on_disconnect()); 199// p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || _ifaceppp->data()->quit_on_disconnect());
200 200
201 comlist = &_ifaceppp->data()->scriptType(); 201 comlist = &_ifaceppp->data()->scriptType();
202 arglist = &_ifaceppp->data()->script(); 202 arglist = &_ifaceppp->data()->script();
203 203
204 QString tit = QObject::tr("Connecting to: %1").arg(_ifaceppp->data()->accname()); 204 QString tit = QObject::tr("Connecting to: %1").arg(_ifaceppp->data()->accname());
205 setCaption(tit); 205 setCaption(tit);
206 206
207 qApp->processEvents(); 207 qApp->processEvents();
208 208
209 // run the "before-connect" command 209 // run the "before-connect" command
210 if (!_ifaceppp->data()->command_before_connect().isEmpty()) { 210 if (!_ifaceppp->data()->command_before_connect().isEmpty()) {
211 messg->setText(QObject::tr("Running pre-startup command...")); 211 messg->setText(QObject::tr("Running pre-startup command..."));
212 emit debugMessage(QObject::tr("Running pre-startup command...")); 212 emit debugMessage(QObject::tr("Running pre-startup command..."));
213 213
214 qApp->processEvents(); 214 qApp->processEvents();
215 QApplication::flushX(); 215 QApplication::flushX();
216 pid_t id = execute_command(_ifaceppp->data()->command_before_connect()); 216 (void)execute_command(_ifaceppp->data()->command_before_connect());
217
217// int i, status; 218// int i, status;
218 219
219// do { 220// do {
220// qApp->processEvents(); 221// qApp->processEvents();
221// i = waitpid(id, &status, WNOHANG); 222// i = waitpid(id, &status, WNOHANG);
222// usleep(100000); 223// usleep(100000);
223// } while (i == 0 && errno == 0); 224// } while (i == 0 && errno == 0);
224 } 225 }
225 226
226 int lock = _ifaceppp->modem()->lockdevice(); 227 int lock = _ifaceppp->modem()->lockdevice();
227 228
228 if (lock == 1) { 229 if (lock == 1) {
229 messg->setText(QObject::tr("Modem device is locked.")); 230 messg->setText(QObject::tr("Modem device is locked."));
230 vmain = 20; // wait until cancel is pressed 231 vmain = 20; // wait until cancel is pressed
231 return; 232 return;
232 } 233 }
233 234
234 if (lock == -1) { 235 if (lock == -1) {
235 messg->setText(QObject::tr("Unable to create modem lock file.")); 236 messg->setText(QObject::tr("Unable to create modem lock file."));
236 vmain = 20; // wait until cancel is pressed 237 vmain = 20; // wait until cancel is pressed
237 return; 238 return;
238 } 239 }
239 240
240 if(_ifaceppp->modem()->opentty()) { 241 if(_ifaceppp->modem()->opentty()) {
241 messg->setText(_ifaceppp->modem()->modemMessage()); 242 messg->setText(_ifaceppp->modem()->modemMessage());
242 qApp->processEvents(); 243 qApp->processEvents();
243 if(_ifaceppp->modem()->hangup()) { 244 if(_ifaceppp->modem()->hangup()) {
244 245
245 qApp->processEvents(); 246 qApp->processEvents();
246 247
247 semaphore = false; 248 semaphore = false;
248 249
249 _ifaceppp->modem()->stop(); 250 _ifaceppp->modem()->stop();
250 _ifaceppp->modem()->notify(this, SLOT(readChar(unsigned char))); 251 _ifaceppp->modem()->notify(this, SLOT(readChar(unsigned char)));
251 252
252 // if we are stuck anywhere we will time out 253 // if we are stuck anywhere we will time out
253 timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); 254 timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000);
254 255
255 // this timer will run the script etc. 256 // this timer will run the script etc.
256 main_timer_ID = startTimer(10); 257 main_timer_ID = startTimer(10);
257 258
258 return; 259 return;
259 } 260 }
260 } 261 }
261 262
262 // initialization failed 263 // initialization failed
263 messg->setText(_ifaceppp->modem()->modemMessage()); 264 messg->setText(_ifaceppp->modem()->modemMessage());
264 vmain = 20; // wait until cancel is pressed 265 vmain = 20; // wait until cancel is pressed
265 _ifaceppp->modem()->unlockdevice(); 266 _ifaceppp->modem()->unlockdevice();
266} 267}
267 268
268 269
269void ConnectWidget::timerEvent(QTimerEvent *) { 270void ConnectWidget::timerEvent(QTimerEvent *) {
270 if (semaphore || pausing) 271 if (semaphore || pausing)
271 return; 272 return;
272 273
273 if(vmain == 0) { 274 if(vmain == 0) {
274#ifdef DEBUG_WO_DIALING 275#ifdef DEBUG_WO_DIALING
275 vmain = 10; 276 vmain = 10;
276 return; 277 return;
277#endif 278#endif
278 279
279 assert(PPPData::NumInitStrings > 0); 280 assert(PPPData::NumInitStrings > 0);
280 // first init string ? 281 // first init string ?
281 if(substate == -1) { 282 if(substate == -1) {
282 messg->setText(QObject::tr("Initializing modem...")); 283 messg->setText(QObject::tr("Initializing modem..."));
283 emit debugMessage(QObject::tr("Initializing modem...")); 284 emit debugMessage(QObject::tr("Initializing modem..."));
284 substate = 0; 285 substate = 0;
285 } 286 }
286 287
287 QString initStr = _ifaceppp->data()->modemInitStr(substate); 288 QString initStr = _ifaceppp->data()->modemInitStr(substate);
288 if (!initStr.isEmpty()) { 289 if (!initStr.isEmpty()) {
289 // send a carriage return and then wait a bit so that the modem will 290 // send a carriage return and then wait a bit so that the modem will
290 // let us issue commands. 291 // let us issue commands.
291 if(_ifaceppp->data()->modemPreInitDelay() > 0) { 292 if(_ifaceppp->data()->modemPreInitDelay() > 0) {
292 usleep(_ifaceppp->data()->modemPreInitDelay() * 5000); 293 usleep(_ifaceppp->data()->modemPreInitDelay() * 5000);
293 writeline(""); 294 writeline("");
294 usleep(_ifaceppp->data()->modemPreInitDelay() * 5000); 295 usleep(_ifaceppp->data()->modemPreInitDelay() * 5000);
295 } 296 }
296 setExpect(_ifaceppp->data()->modemInitResp()); 297 setExpect(_ifaceppp->data()->modemInitResp());
297 writeline(initStr); 298 writeline(initStr);
298 usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec 299 usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec
299 } 300 }
300 301
301 substate++; 302 substate++;
302 303
303 /* 304 /*
304 * FIXME after 3.0: Make it possible to disable ATS11 since it 305 * FIXME after 3.0: Make it possible to disable ATS11 since it
305 * seems to be incompatible with some ISDN adapters (e.g. DataBox 306 * seems to be incompatible with some ISDN adapters (e.g. DataBox
306 * Speed Dragon). Even better would be to detect this when doing 307 * Speed Dragon). Even better would be to detect this when doing
307 * a "Modem Query" 308 * a "Modem Query"
308 */ 309 */
309 if (MODEM_TONEDURATION != _ifaceppp->data()->modemToneDuration()) 310 if (MODEM_TONEDURATION != _ifaceppp->data()->modemToneDuration())
310 vmain = 5; 311 vmain = 5;
311 else 312 else
312 vmain = 3; 313 vmain = 3;
313 314
314 return; 315 return;
315 } 316 }
316 317
317 if (vmain == 5) { 318 if (vmain == 5) {
318 if(!expecting) { 319 if(!expecting) {
319 QString sToneDuration = "ATS11=" + QString::number(_ifaceppp->data()->modemToneDuration()); 320 QString sToneDuration = "ATS11=" + QString::number(_ifaceppp->data()->modemToneDuration());
320 QString msg = QObject::tr("Setting ") + sToneDuration; 321 QString msg = QObject::tr("Setting ") + sToneDuration;
321 messg->setText(msg); 322 messg->setText(msg);
322 emit debugMessage(msg); 323 emit debugMessage(msg);
323 setExpect(_ifaceppp->data()->modemInitResp()); 324 setExpect(_ifaceppp->data()->modemInitResp());
324 writeline(sToneDuration); 325 writeline(sToneDuration);
325 } 326 }
326 vmain = 3; 327 vmain = 3;
327 return; 328 return;
328 } 329 }
329 330
330 if(vmain == 3) { 331 if(vmain == 3) {
331 if(!expecting) { 332 if(!expecting) {
332 // done with all init strings ? 333 // done with all init strings ?
333 if(substate < PPPData::NumInitStrings) { 334 if(substate < PPPData::NumInitStrings) {
334 vmain = 0; 335 vmain = 0;
335 return; 336 return;
336 } 337 }
337 substate = -1; 338 substate = -1;
338 // skip setting the volume if command is empty 339 // skip setting the volume if command is empty
339 if(_ifaceppp->data()->volumeInitString().isEmpty()) { 340 if(_ifaceppp->data()->volumeInitString().isEmpty()) {
340 vmain = 4; 341 vmain = 4;
341 return; 342 return;
342 } 343 }
343 messg->setText(QObject::tr("Setting speaker volume...")); 344 messg->setText(QObject::tr("Setting speaker volume..."));
344 emit debugMessage(QObject::tr("Setting speaker volume...")); 345 emit debugMessage(QObject::tr("Setting speaker volume..."));
345 346
346 setExpect(_ifaceppp->data()->modemInitResp()); 347 setExpect(_ifaceppp->data()->modemInitResp());
347 QString vol("AT"); 348 QString vol("AT");
348 vol += _ifaceppp->data()->volumeInitString(); 349 vol += _ifaceppp->data()->volumeInitString();
349 writeline(vol); 350 writeline(vol);
350 usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec 351 usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec
351 vmain = 4; 352 vmain = 4;
352 return; 353 return;
353 } 354 }
354 } 355 }
355 356
356 if(vmain == 4) { 357 if(vmain == 4) {
357 if(!expecting) { 358 if(!expecting) {
358 if(!_ifaceppp->data()->waitForDialTone()) { 359 if(!_ifaceppp->data()->waitForDialTone()) {
359 QString msg = QObject::tr("Turning off dial tone waiting..."); 360 QString msg = QObject::tr("Turning off dial tone waiting...");
360 messg->setText(msg); 361 messg->setText(msg);
361 emit debugMessage(msg); 362 emit debugMessage(msg);
362 setExpect(_ifaceppp->data()->modemInitResp()); 363 setExpect(_ifaceppp->data()->modemInitResp());
363 writeline(_ifaceppp->data()->modemNoDialToneDetectionStr()); 364 writeline(_ifaceppp->data()->modemNoDialToneDetectionStr());
364 } 365 }
365 vmain = 1; 366 vmain = 1;
366 return; 367 return;
367 } 368 }
368 } 369 }
369 370
370 // dial the number and wait to connect 371 // dial the number and wait to connect
371 if(vmain == 1) { 372 if(vmain == 1) {
372 if(!expecting) { 373 if(!expecting) {
373 374
374 timeout_timer->stop(); 375 timeout_timer->stop();
375 timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); 376 timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000);
376 377
377 QStringList &plist = _ifaceppp->data()->phonenumbers(); 378 QStringList &plist = _ifaceppp->data()->phonenumbers();
378 QString bmarg= _ifaceppp->data()->dialPrefix(); 379 QString bmarg= _ifaceppp->data()->dialPrefix();
379 bmarg += *plist.at(dialnumber); 380 bmarg += *plist.at(dialnumber);
380 QString bm = QObject::tr("Dialing %1").arg(bmarg); 381 QString bm = QObject::tr("Dialing %1").arg(bmarg);
381 messg->setText(bm); 382 messg->setText(bm);
382 emit debugMessage(bm); 383 emit debugMessage(bm);
383 384
384 QString pn = _ifaceppp->data()->modemDialStr(); 385 QString pn = _ifaceppp->data()->modemDialStr();
385 pn += _ifaceppp->data()->dialPrefix(); 386 pn += _ifaceppp->data()->dialPrefix();
386 pn += *plist.at(dialnumber); 387 pn += *plist.at(dialnumber);
387 if(++dialnumber >= plist.count()) 388 if(++dialnumber >= plist.count())
388 dialnumber = 0; 389 dialnumber = 0;
389 writeline(pn); 390 writeline(pn);
390 391
391 setExpect(_ifaceppp->data()->modemConnectResp()); 392 setExpect(_ifaceppp->data()->modemConnectResp());
392 vmain = 100; 393 vmain = 100;
393 return; 394 return;
394 } 395 }
395 } 396 }
396 397
397 // wait for connect, but redial if BUSY or wait for user cancel 398 // wait for connect, but redial if BUSY or wait for user cancel
398 // if NO CARRIER or NO DIALTONE 399 // if NO CARRIER or NO DIALTONE
399 if(vmain == 100) { 400 if(vmain == 100) {
400 if(!expecting) { 401 if(!expecting) {
401 myreadbuffer = _ifaceppp->data()->modemConnectResp(); 402 myreadbuffer = _ifaceppp->data()->modemConnectResp();
402 setExpect("\n"); 403 setExpect("\n");
403 vmain = 101; 404 vmain = 101;
404 return; 405 return;
405 } 406 }
406 407
407 if(readbuffer.contains(_ifaceppp->data()->modemBusyResp())) { 408 if(readbuffer.contains(_ifaceppp->data()->modemBusyResp())) {
408 timeout_timer->stop(); 409 timeout_timer->stop();
409 timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); 410 timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000);
410 411
411 messg->setText(QObject::tr("Line busy. Hanging up...")); 412 messg->setText(QObject::tr("Line busy. Hanging up..."));
412 emit debugPutChar('\n'); 413 emit debugPutChar('\n');
413 _ifaceppp->modem()->hangup(); 414 _ifaceppp->modem()->hangup();
414 415
415 if(_ifaceppp->data()->busyWait() > 0) { 416 if(_ifaceppp->data()->busyWait() > 0) {
416 QString bm = QObject::tr("Line busy. Waiting: %1 seconds").arg(_ifaceppp->data()->busyWait()); 417 QString bm = QObject::tr("Line busy. Waiting: %1 seconds").arg(_ifaceppp->data()->busyWait());
417 messg->setText(bm); 418 messg->setText(bm);
418 emit debugMessage(bm); 419 emit debugMessage(bm);
419 420
420 pausing = true; 421 pausing = true;
421 422
422 pausetimer->start(_ifaceppp->data()->busyWait()*1000, true); 423 pausetimer->start(_ifaceppp->data()->busyWait()*1000, true);
423 timeout_timer->stop(); 424 timeout_timer->stop();
424 } 425 }
425 426
426 _ifaceppp->modem()->setDataMode(false); 427 _ifaceppp->modem()->setDataMode(false);
427 vmain = 0; 428 vmain = 0;
428 substate = -1; 429 substate = -1;
429 return; 430 return;
430 } 431 }
431 432
432 if(readbuffer.contains(_ifaceppp->data()->modemNoDialtoneResp())) { 433 if(readbuffer.contains(_ifaceppp->data()->modemNoDialtoneResp())) {
433 timeout_timer->stop(); 434 timeout_timer->stop();
434 435
435 messg->setText(QObject::tr("No Dialtone")); 436 messg->setText(QObject::tr("No Dialtone"));
436 vmain = 20; 437 vmain = 20;
437 _ifaceppp->modem()->unlockdevice(); 438 _ifaceppp->modem()->unlockdevice();
438 return; 439 return;
439 } 440 }
440 441
441 if(readbuffer.contains(_ifaceppp->data()->modemNoCarrierResp())) { 442 if(readbuffer.contains(_ifaceppp->data()->modemNoCarrierResp())) {
442 timeout_timer->stop(); 443 timeout_timer->stop();
443 444
444 messg->setText(QObject::tr("No Carrier")); 445 messg->setText(QObject::tr("No Carrier"));
445 vmain = 20; 446 vmain = 20;
446 _ifaceppp->modem()->unlockdevice(); 447 _ifaceppp->modem()->unlockdevice();
447 return; 448 return;
448 } 449 }
449 } 450 }
450 451
451 // wait for newline after CONNECT response (so we get the speed) 452 // wait for newline after CONNECT response (so we get the speed)
452 if(vmain == 101) { 453 if(vmain == 101) {
453 if(!expecting) { 454 if(!expecting) {
454 _ifaceppp->modem()->setDataMode(true); // modem will no longer respond to AT commands 455 _ifaceppp->modem()->setDataMode(true); // modem will no longer respond to AT commands
455 456
456 emit startAccounting(); 457 emit startAccounting();
457// p_kppp->con_win->startClock(); 458// p_kppp->con_win->startClock();
458 459
459 vmain = 2; 460 vmain = 2;
460 scriptTimeout=_ifaceppp->data()->modemTimeout()*1000; 461 scriptTimeout=_ifaceppp->data()->modemTimeout()*1000;
461 return; 462 return;
462 } 463 }
463 } 464 }
464 465
465 // execute the script 466 // execute the script
466 if(vmain == 2) { 467 if(vmain == 2) {
467 if(!expecting && !pausing && !scanning) { 468 if(!expecting && !pausing && !scanning) {
468 469
469 timeout_timer->stop(); 470 timeout_timer->stop();
470 timeout_timer->start(scriptTimeout); 471 timeout_timer->start(scriptTimeout);
471 472
472 if((unsigned) scriptindex < comlist->count()) { 473 if((unsigned) scriptindex < comlist->count()) {
473 scriptCommand = *(comlist->at(scriptindex)); 474 scriptCommand = *(comlist->at(scriptindex));
474 scriptArgument = *(arglist->at(scriptindex)); 475 scriptArgument = *(arglist->at(scriptindex));
475 } else { 476 } else {
476 odebug << "End of script" << oendl; 477 odebug << "End of script" << oendl;
477 vmain = 10; 478 vmain = 10;
478 return; 479 return;
479 } 480 }
480 481
481 if (scriptCommand == "Scan") { 482 if (scriptCommand == "Scan") {
482 QString bm = QObject::tr("Scanning %1").arg(scriptArgument); 483 QString bm = QObject::tr("Scanning %1").arg(scriptArgument);
483 messg->setText(bm); 484 messg->setText(bm);
484 emit debugMessage(bm); 485 emit debugMessage(bm);
485 486
486 setScan(scriptArgument); 487 setScan(scriptArgument);
487 scriptindex++; 488 scriptindex++;
488 return; 489 return;
489 } 490 }
490 491
491 if (scriptCommand == "Save") { 492 if (scriptCommand == "Save") {
492 QString bm = QObject::tr("Saving %1").arg(scriptArgument); 493 QString bm = QObject::tr("Saving %1").arg(scriptArgument);
493 messg->setText(bm); 494 messg->setText(bm);
494 emit debugMessage(bm); 495 emit debugMessage(bm);
495 496
496 if (scriptArgument.lower() == "password") { 497 if (scriptArgument.lower() == "password") {
497 _ifaceppp->data()->setPassword(scanvar); 498 _ifaceppp->data()->setPassword(scanvar);
498 // p_kppp->setPW_Edit(scanvar); 499 // p_kppp->setPW_Edit(scanvar);
499 if(_ifaceppp->data()->storePassword()) 500 if(_ifaceppp->data()->storePassword())
500 _ifaceppp->data()->setStoredPassword(scanvar); 501 _ifaceppp->data()->setStoredPassword(scanvar);
501 firstrunPW = true; 502 firstrunPW = true;
502 } 503 }
503 504
504 scriptindex++; 505 scriptindex++;
505 return; 506 return;
506 } 507 }
507 508
508 509
509 if (scriptCommand == "Send" || scriptCommand == "SendNoEcho") { 510 if (scriptCommand == "Send" || scriptCommand == "SendNoEcho") {
510 QString bm = QObject::tr("Sending %1"); 511 QString bm = QObject::tr("Sending %1");
511 512
512 // replace %USERNAME% and %PASSWORD% 513 // replace %USERNAME% and %PASSWORD%
513 QString arg = scriptArgument; 514 QString arg = scriptArgument;
514 QRegExp re1("%USERNAME%"); 515 QRegExp re1("%USERNAME%");
515 QRegExp re2("%PASSWORD%"); 516 QRegExp re2("%PASSWORD%");
516 arg = arg.replace(re1, _ifaceppp->data()->storedUsername()); 517 arg = arg.replace(re1, _ifaceppp->data()->storedUsername());
517 arg = arg.replace(re2, _ifaceppp->data()->storedPassword()); 518 arg = arg.replace(re2, _ifaceppp->data()->storedPassword());
518 519
519 if (scriptCommand == "Send") 520 if (scriptCommand == "Send")
520 bm = bm.arg(scriptArgument); 521 bm = bm.arg(scriptArgument);
521 else { 522 else {
522 for(uint i = 0; i < scriptArgument.length(); i++) 523 for(uint i = 0; i < scriptArgument.length(); i++)
523 bm = bm.arg("*"); 524 bm = bm.arg("*");
524 } 525 }
525 526
526 messg->setText(bm); 527 messg->setText(bm);
527 emit debugMessage(bm); 528 emit debugMessage(bm);
528 529
529 writeline(scriptArgument); 530 writeline(scriptArgument);
530 scriptindex++; 531 scriptindex++;
531 return; 532 return;
532 } 533 }
533 534
534 if (scriptCommand == "Expect") { 535 if (scriptCommand == "Expect") {
535 QString bm = QObject::tr("Expecting %1").arg(scriptArgument); 536 QString bm = QObject::tr("Expecting %1").arg(scriptArgument);
536 messg->setText(bm); 537 messg->setText(bm);
537 emit debugMessage(bm); 538 emit debugMessage(bm);
538 539
539 // The incrementing of the scriptindex MUST be before the 540 // The incrementing of the scriptindex MUST be before the
540 // call to setExpect otherwise the expect will miss a string that is 541 // call to setExpect otherwise the expect will miss a string that is
541 // already in the buffer. 542 // already in the buffer.
542 scriptindex++; 543 scriptindex++;
543 setExpect(scriptArgument); 544 setExpect(scriptArgument);
544 return; 545 return;
545 } 546 }
546 547
547 548
548 if (scriptCommand == "Pause") { 549 if (scriptCommand == "Pause") {
549 QString bm = QObject::tr("Pause %1 seconds").arg(scriptArgument); 550 QString bm = QObject::tr("Pause %1 seconds").arg(scriptArgument);
550 messg->setText(bm); 551 messg->setText(bm);
551 emit debugMessage(bm); 552 emit debugMessage(bm);
552 553
553 pausing = true; 554 pausing = true;
554 555
555 pausetimer->start(scriptArgument.toInt()*1000, true); 556 pausetimer->start(scriptArgument.toInt()*1000, true);
556 timeout_timer->stop(); 557 timeout_timer->stop();
557 558
558 scriptindex++; 559 scriptindex++;
559 return; 560 return;
560 } 561 }
561 562
562 if (scriptCommand == "Timeout") { 563 if (scriptCommand == "Timeout") {
563 564
564 timeout_timer->stop(); 565 timeout_timer->stop();
565 566
566 QString bm = QObject::tr("Timeout %1 seconds").arg(scriptArgument); 567 QString bm = QObject::tr("Timeout %1 seconds").arg(scriptArgument);
567 messg->setText(bm); 568 messg->setText(bm);
568 emit debugMessage(bm); 569 emit debugMessage(bm);
569 570
570 scriptTimeout=scriptArgument.toInt()*1000; 571 scriptTimeout=scriptArgument.toInt()*1000;
571 timeout_timer->start(scriptTimeout); 572 timeout_timer->start(scriptTimeout);
572 573
573 scriptindex++; 574 scriptindex++;
574 return; 575 return;
575 } 576 }
576 577
577 if (scriptCommand == "Hangup") { 578 if (scriptCommand == "Hangup") {
578 messg->setText(QObject::tr("Hangup")); 579 messg->setText(QObject::tr("Hangup"));
579 emit debugMessage(QObject::tr("Hangup")); 580 emit debugMessage(QObject::tr("Hangup"));
580 581
581 writeline(_ifaceppp->data()->modemHangupStr()); 582 writeline(_ifaceppp->data()->modemHangupStr());
582 setExpect(_ifaceppp->data()->modemHangupResp()); 583 setExpect(_ifaceppp->data()->modemHangupResp());
583 584
584 scriptindex++; 585 scriptindex++;
585 return; 586 return;
586 } 587 }
587 588
588 if (scriptCommand == "Answer") { 589 if (scriptCommand == "Answer") {
589 590
590 timeout_timer->stop(); 591 timeout_timer->stop();
591 592
592 messg->setText(QObject::tr("Answer")); 593 messg->setText(QObject::tr("Answer"));
593 emit debugMessage(QObject::tr("Answer")); 594 emit debugMessage(QObject::tr("Answer"));
594 595
595 setExpect(_ifaceppp->data()->modemRingResp()); 596 setExpect(_ifaceppp->data()->modemRingResp());
596 vmain = 150; 597 vmain = 150;
597 return; 598 return;
598 } 599 }
599 600
600 if (scriptCommand == "ID") { 601 if (scriptCommand == "ID") {
601 QString bm = QObject::tr("ID %1").arg(scriptArgument); 602 QString bm = QObject::tr("ID %1").arg(scriptArgument);
602 messg->setText(bm); 603 messg->setText(bm);
603 emit debugMessage(bm); 604 emit debugMessage(bm);
604 605
605 QString idstring = _ifaceppp->data()->password(); 606 QString idstring = _ifaceppp->data()->password();
606 607
607 if(!idstring.isEmpty() && firstrunID) { 608 if(!idstring.isEmpty() && firstrunID) {
608 // the user entered an Id on the main kppp dialog 609 // the user entered an Id on the main kppp dialog
609 writeline(idstring); 610 writeline(idstring);
610 firstrunID = false; 611 firstrunID = false;
611 scriptindex++; 612 scriptindex++;
612 } 613 }
613 else { 614 else {
614 // the user didn't enter and Id on the main kppp dialog 615 // the user didn't enter and Id on the main kppp dialog
615 // let's query for an ID 616 // let's query for an ID
616 /* if not around yet, then post window... */ 617 /* if not around yet, then post window... */
617 if (prompt->Consumed()) { 618 if (prompt->Consumed()) {
618 if (!(prompt->isVisible())) { 619 if (!(prompt->isVisible())) {
619 prompt->setPrompt(scriptArgument); 620 prompt->setPrompt(scriptArgument);
620 prompt->setEchoModeNormal(); 621 prompt->setEchoModeNormal();
621 prompt->show(); 622 prompt->show();
622 } 623 }
623 } else { 624 } else {
624 /* if prompt withdrawn ... then, */ 625 /* if prompt withdrawn ... then, */
625 if(!(prompt->isVisible())) { 626 if(!(prompt->isVisible())) {
626 writeline(prompt->text()); 627 writeline(prompt->text());
627 prompt->setConsumed(); 628 prompt->setConsumed();
628 scriptindex++; 629 scriptindex++;
629 return; 630 return;
630 } 631 }
631 /* replace timeout value */ 632 /* replace timeout value */
632 } 633 }
633 } 634 }
634 } 635 }
635 636
636 if (scriptCommand == "Password") { 637 if (scriptCommand == "Password") {
637 QString bm = QObject::tr("Password %1").arg(scriptArgument); 638 QString bm = QObject::tr("Password %1").arg(scriptArgument);
638 messg->setText(bm); 639 messg->setText(bm);
639 emit debugMessage(bm); 640 emit debugMessage(bm);
640 641
641 QString pwstring = _ifaceppp->data()->password(); 642 QString pwstring = _ifaceppp->data()->password();
642 643
643 if(!pwstring.isEmpty() && firstrunPW) { 644 if(!pwstring.isEmpty() && firstrunPW) {
644 // the user entered a password on the main kppp dialog 645 // the user entered a password on the main kppp dialog
645 writeline(pwstring); 646 writeline(pwstring);
646 firstrunPW = false; 647 firstrunPW = false;
647 scriptindex++; 648 scriptindex++;
648 } 649 }
649 else { 650 else {
650 // the user didn't enter a password on the main kppp dialog 651 // the user didn't enter a password on the main kppp dialog
651 // let's query for a password 652 // let's query for a password
652 /* if not around yet, then post window... */ 653 /* if not around yet, then post window... */
653 if (prompt->Consumed()) { 654 if (prompt->Consumed()) {
654 if (!(prompt->isVisible())) { 655 if (!(prompt->isVisible())) {
655 prompt->setPrompt(scriptArgument); 656 prompt->setPrompt(scriptArgument);
656 prompt->setEchoModePassword(); 657 prompt->setEchoModePassword();
657 prompt->show(); 658 prompt->show();
658 } 659 }
659 } else { 660 } else {
660 /* if prompt withdrawn ... then, */ 661 /* if prompt withdrawn ... then, */
661 if(!(prompt->isVisible())) { 662 if(!(prompt->isVisible())) {
662 // p_kppp->setPW_Edit(prompt->text()); 663 // p_kppp->setPW_Edit(prompt->text());
663 writeline(prompt->text()); 664 writeline(prompt->text());
664 prompt->setConsumed(); 665 prompt->setConsumed();
665 scriptindex++; 666 scriptindex++;
666 return; 667 return;
667 } 668 }
668 /* replace timeout value */ 669 /* replace timeout value */
669 } 670 }
670 } 671 }
671 } 672 }
672 673
673 if (scriptCommand == "Prompt") { 674 if (scriptCommand == "Prompt") {
674 QString bm = QObject::tr("Prompting %1"); 675 QString bm = QObject::tr("Prompting %1");
675 676
676 // if the scriptindex (aka the prompt text) includes a ## marker 677 // if the scriptindex (aka the prompt text) includes a ## marker
677 // this marker should get substituted with the contents of our stored 678 // this marker should get substituted with the contents of our stored
678 // variable (from the subsequent scan). 679 // variable (from the subsequent scan).
679 680
680 QString ts = scriptArgument; 681 QString ts = scriptArgument;
681 int vstart = ts.find( "##" ); 682 int vstart = ts.find( "##" );
682 if( vstart != -1 ) { 683 if( vstart != -1 ) {
683 ts.remove( vstart, 2 ); 684 ts.remove( vstart, 2 );
684 ts.insert( vstart, scanvar ); 685 ts.insert( vstart, scanvar );
685 } 686 }
686 687
687 bm = bm.arg(ts); 688 bm = bm.arg(ts);
688 messg->setText(bm); 689 messg->setText(bm);
689 emit debugMessage(bm); 690 emit debugMessage(bm);
690 691
691 /* if not around yet, then post window... */ 692 /* if not around yet, then post window... */
692 if (prompt->Consumed()) { 693 if (prompt->Consumed()) {
693 if (!(prompt->isVisible())) { 694 if (!(prompt->isVisible())) {
694 prompt->setPrompt( ts ); 695 prompt->setPrompt( ts );
695 prompt->setEchoModeNormal(); 696 prompt->setEchoModeNormal();
696 prompt->show(); 697 prompt->show();
697 } 698 }
698 } else { 699 } else {
699 /* if prompt withdrawn ... then, */ 700 /* if prompt withdrawn ... then, */
700 if (!(prompt->isVisible())) { 701 if (!(prompt->isVisible())) {
701 writeline(prompt->text()); 702 writeline(prompt->text());
702 prompt->setConsumed(); 703 prompt->setConsumed();
703 scriptindex++; 704 scriptindex++;
704 return; 705 return;
705 } 706 }
706 /* replace timeout value */ 707 /* replace timeout value */
707 } 708 }
708 } 709 }
709 710
710 if (scriptCommand == "PWPrompt") { 711 if (scriptCommand == "PWPrompt") {
711 QString bm = QObject::tr("PW Prompt %1").arg(scriptArgument); 712 QString bm = QObject::tr("PW Prompt %1").arg(scriptArgument);
712 messg->setText(bm); 713 messg->setText(bm);
713 emit debugMessage(bm); 714 emit debugMessage(bm);
714 715
715 /* if not around yet, then post window... */ 716 /* if not around yet, then post window... */
716 if (prompt->Consumed()) { 717 if (prompt->Consumed()) {
717 if (!(prompt->isVisible())) { 718 if (!(prompt->isVisible())) {
718 prompt->setPrompt(scriptArgument); 719 prompt->setPrompt(scriptArgument);
719 prompt->setEchoModePassword(); 720 prompt->setEchoModePassword();
720 prompt->show(); 721 prompt->show();
721 } 722 }
722 } else { 723 } else {
723 /* if prompt withdrawn ... then, */ 724 /* if prompt withdrawn ... then, */
724 if (!(prompt->isVisible())) { 725 if (!(prompt->isVisible())) {
725 writeline(prompt->text()); 726 writeline(prompt->text());
726 prompt->setConsumed(); 727 prompt->setConsumed();
727 scriptindex++; 728 scriptindex++;
728 return; 729 return;
729 } 730 }
730 /* replace timeout value */ 731 /* replace timeout value */
731 } 732 }
732 } 733 }
733 734
734 if (scriptCommand == "LoopStart") { 735 if (scriptCommand == "LoopStart") {
735 736
736 QString bm = QObject::tr("Loop Start %1").arg(scriptArgument); 737 QString bm = QObject::tr("Loop Start %1").arg(scriptArgument);
737 738
738 // The incrementing of the scriptindex MUST be before the 739 // The incrementing of the scriptindex MUST be before the
739 // call to setExpect otherwise the expect will miss a string that is 740 // call to setExpect otherwise the expect will miss a string that is
740 // already in the buffer. 741 // already in the buffer.
741 scriptindex++; 742 scriptindex++;
742 743
743 if ( loopnest > (MAXLOOPNEST-2) ) { 744 if ( loopnest > (MAXLOOPNEST-2) ) {
744 bm += QObject::tr("ERROR: Nested too deep, ignored."); 745 bm += QObject::tr("ERROR: Nested too deep, ignored.");
745 vmain=20; 746 vmain=20;
746 cancelbutton(); 747 cancelbutton();
747 QMessageBox::critical(0, "error", QObject::tr("Loops nested too deeply!")); 748 QMessageBox::critical(0, "error", QObject::tr("Loops nested too deeply!"));
748 } else { 749 } else {
749 setExpect(scriptArgument); 750 setExpect(scriptArgument);
750 loopstartindex[loopnest] = scriptindex; 751 loopstartindex[loopnest] = scriptindex;
751 loopstr[loopnest] = scriptArgument; 752 loopstr[loopnest] = scriptArgument;
752 loopend = false; 753 loopend = false;
753 loopnest++; 754 loopnest++;
754 } 755 }
755 messg->setText(bm); 756 messg->setText(bm);
756 emit debugMessage(bm); 757 emit debugMessage(bm);
757 758
758 } 759 }
759 760
760 if (scriptCommand == "LoopEnd") { 761 if (scriptCommand == "LoopEnd") {
761 QString bm = QObject::tr("Loop End %1").arg(scriptArgument); 762 QString bm = QObject::tr("Loop End %1").arg(scriptArgument);
762 if ( loopnest <= 0 ) { 763 if ( loopnest <= 0 ) {
763 bm = QObject::tr("LoopEnd without matching Start! Line: %1").arg(bm); 764 bm = QObject::tr("LoopEnd without matching Start! Line: %1").arg(bm);
764 vmain=20; 765 vmain=20;
765 cancelbutton(); 766 cancelbutton();
766 QMessageBox::critical(0, "error", bm); 767 QMessageBox::critical(0, "error", bm);
767 return; 768 return;
768 } else { 769 } else {
769 // NB! The incrementing of the scriptindex MUST be before the 770 // NB! The incrementing of the scriptindex MUST be before the
770 // call to setExpect otherwise the expect will miss a string 771 // call to setExpect otherwise the expect will miss a string
771 // that is already in the buffer. 772 // that is already in the buffer.
772 scriptindex++; 773 scriptindex++;
773 setExpect(scriptArgument); 774 setExpect(scriptArgument);
774 loopnest--; 775 loopnest--;
775 loopend = true; 776 loopend = true;
776 } 777 }
777 messg->setText(bm); 778 messg->setText(bm);
778 emit debugMessage(bm); 779 emit debugMessage(bm);
779 780
780 } 781 }
781 } 782 }
782 } 783 }
783 784
784 // this is a subroutine for the "Answer" script option 785 // this is a subroutine for the "Answer" script option
785 786
786 if(vmain == 150) { 787 if(vmain == 150) {
787 if(!expecting) { 788 if(!expecting) {
788 writeline(_ifaceppp->data()->modemAnswerStr()); 789 writeline(_ifaceppp->data()->modemAnswerStr());
789 setExpect(_ifaceppp->data()->modemAnswerResp()); 790 setExpect(_ifaceppp->data()->modemAnswerResp());
790 791
791 vmain = 2; 792 vmain = 2;
792 scriptindex++; 793 scriptindex++;
793 return; 794 return;
794 } 795 }
795 } 796 }
796 797
797 if(vmain == 30) { 798 if(vmain == 30) {
798// if (termwindow->isVisible()) 799// if (termwindow->isVisible())
799// return; 800// return;
800// if (termwindow->pressedContinue()) 801// if (termwindow->pressedContinue())
801// vmain = 10; 802// vmain = 10;
802// else 803// else
803 cancelbutton(); 804 cancelbutton();
804 } 805 }
805 806
806 if(vmain == 10) { 807 if(vmain == 10) {
807 if(!expecting) { 808 if(!expecting) {
808 809
809 int result; 810 int result;
810 811
811 timeout_timer->stop(); 812 timeout_timer->stop();
812 if_timeout_timer->stop(); // better be sure. 813 if_timeout_timer->stop(); // better be sure.
813 814
814 // stop reading of data 815 // stop reading of data
815 _ifaceppp->modem()->stop(); 816 _ifaceppp->modem()->stop();
816 817
817 if(_ifaceppp->data()->authMethod() == AUTH_TERMINAL) { 818 if(_ifaceppp->data()->authMethod() == AUTH_TERMINAL) {
818 // if (termwindow) { 819 // if (termwindow) {
819 // delete termwindow; 820 // delete termwindow;
820 // termwindow = 0L; 821 // termwindow = 0L;
821 // this->show(); 822 // this->show();
822 // } else { 823 // } else {
823 // termwindow = new LoginTerm(0L, 0L); 824 // termwindow = new LoginTerm(0L, 0L);
824 // hide(); 825 // hide();
825 // termwindow->show(); 826 // termwindow->show();
826 // vmain = 30; 827 // vmain = 30;
827 // return; 828 // return;
828 // } 829 // }
829 } 830 }
830 831
831 // Close the tty. This prevents the QTimer::singleShot() in 832 // Close the tty. This prevents the QTimer::singleShot() in
832 // Modem::readtty() from re-enabling the socket notifier. 833 // Modem::readtty() from re-enabling the socket notifier.
833 // The port is still held open by the helper process. 834 // The port is still held open by the helper process.
834 835
835 /* Er, there _is_ not QTimer::singleShot() in Modem::readtty(), 836 /* Er, there _is_ not QTimer::singleShot() in Modem::readtty(),
836 and closing the thing prevents pppd from using it later. */ 837 and closing the thing prevents pppd from using it later. */
837 //_ifaceppp->modem()->closetty(); 838 //_ifaceppp->modem()->closetty();
838 839
839 killTimer( main_timer_ID ); 840 killTimer( main_timer_ID );
840 841
841 if_timeout_timer->start(_ifaceppp->data()->pppdTimeout()*1000); 842 if_timeout_timer->start(_ifaceppp->data()->pppdTimeout()*1000);
842 odebug << "started if timeout timer with " << _ifaceppp->data()->pppdTimeout()*1000 << "" << oendl; 843 odebug << "started if timeout timer with " << _ifaceppp->data()->pppdTimeout()*1000 << "" << oendl;
843 844
844 // find out PPP interface and notify the stats module 845 // find out PPP interface and notify the stats module
845// stats->setUnit(pppInterfaceNumber()); 846// stats->setUnit(pppInterfaceNumber());
846 847
847 qApp->flushX(); 848 qApp->flushX();
848 semaphore = true; 849 semaphore = true;
849 result = execppp(); 850 result = execppp();
850 851
851 emit debugMessage(QObject::tr("Starting pppd...")); 852 emit debugMessage(QObject::tr("Starting pppd..."));
852 odebug << "execppp() returned with return-code " << result << "" << oendl; 853 odebug << "execppp() returned with return-code " << result << "" << oendl;
853 854
854 if(result) { 855 if(result) {
855 if(!_ifaceppp->data()->autoDNS()) 856 if(!_ifaceppp->data()->autoDNS())
856 adddns( _ifaceppp ); 857 adddns( _ifaceppp );
857 858
858 // O.K we are done here, let's change over to the if_waiting loop 859 // O.K we are done here, let's change over to the if_waiting loop
859 // where we wait for the ppp if (interface) to come up. 860 // where we wait for the ppp if (interface) to come up.
860 861
861 emit if_waiting_signal(); 862 emit if_waiting_signal();
862 } else { 863 } else {
863 864
864 // starting pppd wasn't successful. Error messages were 865 // starting pppd wasn't successful. Error messages were
865 // handled by execppp(); 866 // handled by execppp();
866 if_timeout_timer->stop(); 867 if_timeout_timer->stop();
867 this->hide(); 868 this->hide();
868 messg->setText(""); 869 messg->setText("");
869 //p_kppp->quit_b->setFocus(); 870 //p_kppp->quit_b->setFocus();
870 //p_kppp->show(); 871 //p_kppp->show();
871 qApp->processEvents(); 872 qApp->processEvents();
872 _ifaceppp->modem()->hangup(); 873 _ifaceppp->modem()->hangup();
873 emit stopAccounting(); 874 emit stopAccounting();
874 //p_kppp->con_win->stopClock(); 875 //p_kppp->con_win->stopClock();
875 _ifaceppp->modem()->closetty(); 876 _ifaceppp->modem()->closetty();
876 _ifaceppp->modem()->unlockdevice(); 877 _ifaceppp->modem()->unlockdevice();
877 878
878 } 879 }
879 880
880 return; 881 return;
881 } 882 }
882 } 883 }
883 884
884 // this is a "wait until cancel" entry 885 // this is a "wait until cancel" entry
885 886
886 if(vmain == 20) { 887 if(vmain == 20) {
887 } 888 }
888} 889}
889 890
890 891
891void ConnectWidget::set_con_speed_string() { 892void ConnectWidget::set_con_speed_string() {
892 // Here we are trying to determine the speed at which we are connected. 893 // Here we are trying to determine the speed at which we are connected.
893 // Usually the modem responds after connect with something like 894 // Usually the modem responds after connect with something like
894 // CONNECT 115200, so all we need to do is find the number after CONNECT 895 // CONNECT 115200, so all we need to do is find the number after CONNECT
895 // or whatever the modemConnectResp() is. 896 // or whatever the modemConnectResp() is.
896// p_kppp->con_speed = _ifaceppp->modem()->parseModemSpeed(myreadbuffer); 897// p_kppp->con_speed = _ifaceppp->modem()->parseModemSpeed(myreadbuffer);
897} 898}
898 899
899 900
900 901
901void ConnectWidget::readChar(unsigned char c) { 902void ConnectWidget::readChar(unsigned char c) {
902 if(semaphore) 903 if(semaphore)
903 return; 904 return;
904 905
905 readbuffer += c; 906 readbuffer += c;
906 myreadbuffer += c; 907 myreadbuffer += c;
907 908
908 // While in scanning mode store each char to the scan buffer 909 // While in scanning mode store each char to the scan buffer
909 // for use in the prompt command 910 // for use in the prompt command
910 if( scanning ) 911 if( scanning )
911 scanbuffer += c; 912 scanbuffer += c;
912 913
913 // add to debug window 914 // add to debug window
914 emit debugPutChar(c); 915 emit debugPutChar(c);
915 916
916 checkBuffers(); 917 checkBuffers();
917} 918}
918 919
919 920
920void ConnectWidget::checkBuffers() { 921void ConnectWidget::checkBuffers() {
921 // Let's check if we are finished with scanning: 922 // Let's check if we are finished with scanning:
922 // The scanstring have to be in the buffer and the latest character 923 // The scanstring have to be in the buffer and the latest character
923 // was a carriage return or an linefeed (depending on modem setup) 924 // was a carriage return or an linefeed (depending on modem setup)
924 if( scanning && scanbuffer.contains(scanstr) && 925 if( scanning && scanbuffer.contains(scanstr) &&
925 ( scanbuffer.right(1) == "\n" || scanbuffer.right(1) == "\r") ) { 926 ( scanbuffer.right(1) == "\n" || scanbuffer.right(1) == "\r") ) {
926 scanning = false; 927 scanning = false;
927 928
928 int vstart = scanbuffer.find( scanstr ) + scanstr.length(); 929 int vstart = scanbuffer.find( scanstr ) + scanstr.length();
929 scanvar = scanbuffer.mid( vstart, scanbuffer.length() - vstart); 930 scanvar = scanbuffer.mid( vstart, scanbuffer.length() - vstart);
930 scanvar = scanvar.stripWhiteSpace(); 931 scanvar = scanvar.stripWhiteSpace();
931 932
932 // Show the Variabel content in the debug window 933 // Show the Variabel content in the debug window
933 QString sv = QObject::tr("Scan Var: %1").arg(scanvar); 934 QString sv = QObject::tr("Scan Var: %1").arg(scanvar);
934 emit debugMessage(sv); 935 emit debugMessage(sv);
935 } 936 }
936 937
937 if(expecting) { 938 if(expecting) {
938 if(readbuffer.contains(expectstr)) { 939 if(readbuffer.contains(expectstr)) {
939 expecting = false; 940 expecting = false;
940 // keep everything after the expected string 941 // keep everything after the expected string
941 readbuffer.remove(0, readbuffer.find(expectstr) + expectstr.length()); 942 readbuffer.remove(0, readbuffer.find(expectstr) + expectstr.length());
942 943
943 QString ts = QObject::tr("Found: %1").arg(expectstr); 944 QString ts = QObject::tr("Found: %1").arg(expectstr);
944 emit debugMessage(ts); 945 emit debugMessage(ts);
945 946
946 if (loopend) { 947 if (loopend) {
947 loopend=false; 948 loopend=false;
948 } 949 }
949 } 950 }
950 951
951 if (loopend && readbuffer.contains(loopstr[loopnest])) { 952 if (loopend && readbuffer.contains(loopstr[loopnest])) {
952 expecting = false; 953 expecting = false;
953 readbuffer = ""; 954 readbuffer = "";
954 QString ts = QObject::tr("Looping: %1").arg(loopstr[loopnest]); 955 QString ts = QObject::tr("Looping: %1").arg(loopstr[loopnest]);
955 emit debugMessage(ts); 956 emit debugMessage(ts);
956 scriptindex = loopstartindex[loopnest]; 957 scriptindex = loopstartindex[loopnest];
957 loopend = false; 958 loopend = false;
958 loopnest++; 959 loopnest++;
959 } 960 }
960 // notify event loop if expected string was found 961 // notify event loop if expected string was found
961 if(!expecting) 962 if(!expecting)
962 timerEvent((QTimerEvent *) 0); 963 timerEvent((QTimerEvent *) 0);
963 } 964 }
964} 965}
965 966
966 967
967 968
968void ConnectWidget::pause() { 969void ConnectWidget::pause() {
969 pausing = false; 970 pausing = false;
970 pausetimer->stop(); 971 pausetimer->stop();
971} 972}
972 973
973 974
974void ConnectWidget::cancelbutton() { 975void ConnectWidget::cancelbutton() {
975 _ifaceppp->modem()->stop(); 976 _ifaceppp->modem()->stop();
976 killTimer(main_timer_ID); 977 killTimer(main_timer_ID);
977 timeout_timer->stop(); 978 timeout_timer->stop();
978 if_timer->stop(); 979 if_timer->stop();
979 if_timeout_timer->stop(); 980 if_timeout_timer->stop();
980 981
981// if (termwindow) { 982// if (termwindow) {
982// delete termwindow; 983// delete termwindow;
983// termwindow = 0L; 984// termwindow = 0L;
984// this->show(); 985// this->show();
985// } 986// }
986 987
987 messg->setText(QObject::tr("One moment please...")); 988 messg->setText(QObject::tr("One moment please..."));
988 989
989 // just to be sure 990 // just to be sure
990 _ifaceppp->modem()->removeSecret(AUTH_PAP); 991 _ifaceppp->modem()->removeSecret(AUTH_PAP);
991 _ifaceppp->modem()->removeSecret(AUTH_CHAP); 992 _ifaceppp->modem()->removeSecret(AUTH_CHAP);
992 removedns(_ifaceppp); 993 removedns(_ifaceppp);
993 994
994 qApp->processEvents(); 995 qApp->processEvents();
995 996
996 _ifaceppp->modem()->killPPPDaemon(); 997 _ifaceppp->modem()->killPPPDaemon();
997 _ifaceppp->modem()->hangup(); 998 _ifaceppp->modem()->hangup();
998 999
999 1000
1000// p_kppp->quit_b->setFocus(); 1001// p_kppp->quit_b->setFocus();
1001// p_kppp->show(); 1002// p_kppp->show();
1002 // emit stopAccounting();// just to be sure 1003 // emit stopAccounting();// just to be sure
1003// p_kppp->con_win->stopClock(); 1004// p_kppp->con_win->stopClock();
1004 _ifaceppp->modem()->closetty(); 1005 _ifaceppp->modem()->closetty();
1005 _ifaceppp->modem()->unlockdevice(); 1006 _ifaceppp->modem()->unlockdevice();
1006 1007
1007 //abort prompt window... 1008 //abort prompt window...
1008 if (prompt->isVisible()) { 1009 if (prompt->isVisible()) {
1009 prompt->hide(); 1010 prompt->hide();
1010 } 1011 }
1011 prompt->setConsumed(); 1012 prompt->setConsumed();
1012 1013
1013 _ifaceppp->setStatus( false ); 1014 _ifaceppp->setStatus( false );
1014 _ifaceppp->refresh(); 1015 _ifaceppp->refresh();
1015// messg->setText(tr("offline")); 1016// messg->setText(tr("offline"));
1016 refresh(); 1017 refresh();
1017} 1018}
1018 1019
1019 1020
1020void ConnectWidget::script_timed_out() { 1021void ConnectWidget::script_timed_out() {
1021 if(vmain == 20) { // we are in the 'wait for the user to cancel' state 1022 if(vmain == 20) { // we are in the 'wait for the user to cancel' state
1022 timeout_timer->stop(); 1023 timeout_timer->stop();
1023 emit stopAccounting(); 1024 emit stopAccounting();
1024// p_kppp->con_win->stopClock(); 1025// p_kppp->con_win->stopClock();
1025 return; 1026 return;
1026 } 1027 }
1027 1028
1028 if (prompt->isVisible()) 1029 if (prompt->isVisible())
1029 prompt->hide(); 1030 prompt->hide();
1030 1031
1031 prompt->setConsumed(); 1032 prompt->setConsumed();
1032 messg->setText(QObject::tr("Script timed out!")); 1033 messg->setText(QObject::tr("Script timed out!"));
1033 _ifaceppp->modem()->hangup(); 1034 _ifaceppp->modem()->hangup();
1034 emit stopAccounting(); 1035 emit stopAccounting();
1035// p_kppp->con_win->stopClock(); 1036// p_kppp->con_win->stopClock();
1036 1037
1037 vmain = 0; // let's try again. 1038 vmain = 0; // let's try again.
1038 substate = -1; 1039 substate = -1;
1039} 1040}
1040 1041
1041 1042
1042void ConnectWidget::setScan(const QString &n) { 1043void ConnectWidget::setScan(const QString &n) {
1043 scanning = true; 1044 scanning = true;
1044 scanstr = n; 1045 scanstr = n;
1045 scanbuffer = ""; 1046 scanbuffer = "";
1046 1047
1047 QString ts = QObject::tr("Scanning: %1").arg(n); 1048 QString ts = QObject::tr("Scanning: %1").arg(n);
1048 emit debugMessage(ts); 1049 emit debugMessage(ts);
1049} 1050}
1050 1051
1051 1052
1052void ConnectWidget::setExpect(const QString &n) { 1053void ConnectWidget::setExpect(const QString &n) {
1053 expecting = true; 1054 expecting = true;
1054 expectstr = n; 1055 expectstr = n;
1055 1056
1056 QString ts = QObject::tr("Expecting: %1").arg(n); 1057 QString ts = QObject::tr("Expecting: %1").arg(n);
1057 ts.replace(QRegExp("\n"), "<LF>"); 1058 ts.replace(QRegExp("\n"), "<LF>");
1058 emit debugMessage(ts); 1059 emit debugMessage(ts);
1059 1060
1060 // check if the expected string is in the read buffer already. 1061 // check if the expected string is in the read buffer already.
1061 checkBuffers(); 1062 checkBuffers();
1062} 1063}
1063 1064
1064 1065
1065void ConnectWidget::if_waiting_timed_out() { 1066void ConnectWidget::if_waiting_timed_out() {
1066 if_timer->stop(); 1067 if_timer->stop();
1067 if_timeout_timer->stop(); 1068 if_timeout_timer->stop();
1068 odebug << "if_waiting_timed_out()" << oendl; 1069 odebug << "if_waiting_timed_out()" << oendl;
1069 1070
1070 _ifaceppp->data()->setpppdError(E_IF_TIMEOUT); 1071 _ifaceppp->data()->setpppdError(E_IF_TIMEOUT);
1071 1072
1072 // let's kill the stuck pppd 1073 // let's kill the stuck pppd
1073 _ifaceppp->modem()->killPPPDaemon(); 1074 _ifaceppp->modem()->killPPPDaemon();
1074 1075
1075 emit stopAccounting(); 1076 emit stopAccounting();
1076// p_kppp->con_win->stopClock(); 1077// p_kppp->con_win->stopClock();
1077 1078
1078 1079
1079 // killing ppp will generate a SIGCHLD which will be caught in pppdie() 1080 // killing ppp will generate a SIGCHLD which will be caught in pppdie()
1080 // in main.cpp what happens next will depend on the boolean 1081 // in main.cpp what happens next will depend on the boolean
1081 // reconnect_on_disconnect which is set in ConnectWidget::init(); 1082 // reconnect_on_disconnect which is set in ConnectWidget::init();
1082} 1083}
1083 1084
1084void ConnectWidget::pppdDied() 1085void ConnectWidget::pppdDied()
1085{ 1086{
1086 if_timer->stop(); 1087 if_timer->stop();
1087 if_timeout_timer->stop(); 1088 if_timeout_timer->stop();
1088} 1089}
1089 1090
1090void ConnectWidget::if_waiting_slot() { 1091void ConnectWidget::if_waiting_slot() {
1091 messg->setText(QObject::tr("Logging on to network...")); 1092 messg->setText(QObject::tr("Logging on to network..."));
1092 1093
1093// if(!stats->ifIsUp()) { 1094// if(!stats->ifIsUp()) {
1094 1095
1095// if(_ifaceppp->data()->pppdError() != 0) { 1096// if(_ifaceppp->data()->pppdError() != 0) {
1096// // we are here if pppd died immediately after starting it. 1097// // we are here if pppd died immediately after starting it.
1097// pppdDied(); 1098// pppdDied();
1098// // error message handled in main.cpp: sigPPPDDied() 1099// // error message handled in main.cpp: sigPPPDDied()
1099// return; 1100// return;
1100// } 1101// }
1101 1102
1102// if_timer->start(100, TRUE); // single shot 1103// if_timer->start(100, TRUE); // single shot
1103// return; 1104// return;
1104// } 1105// }
1105 1106
1106 // O.K the ppp interface is up and running 1107 // O.K the ppp interface is up and running
1107 // give it a few time to come up completly (0.2 seconds) 1108 // give it a few time to come up completly (0.2 seconds)
1108 if_timeout_timer->stop(); 1109 if_timeout_timer->stop();
1109 if_timer->stop(); 1110 if_timer->stop();
1110 usleep(200000); 1111 usleep(200000);
1111 1112
1112 if(_ifaceppp->data()->autoDNS()) 1113 if(_ifaceppp->data()->autoDNS())
1113 addpeerdns( _ifaceppp ); 1114 addpeerdns( _ifaceppp );
1114 1115
1115 // Close the debugging window. If we are connected, we 1116 // Close the debugging window. If we are connected, we
1116 // are not really interested in debug output 1117 // are not really interested in debug output
1117 emit closeDebugWindow(); 1118 emit closeDebugWindow();
1118// p_kppp->statdlg->take_stats(); // start taking ppp statistics 1119// p_kppp->statdlg->take_stats(); // start taking ppp statistics
1119 auto_hostname(_ifaceppp); 1120 auto_hostname(_ifaceppp);
1120 1121
1121 if(!_ifaceppp->data()->command_on_connect().isEmpty()) { 1122 if(!_ifaceppp->data()->command_on_connect().isEmpty()) {
1122 messg->setText(QObject::tr("Running startup command...")); 1123 messg->setText(QObject::tr("Running startup command..."));
1123 1124
1124 // make sure that we don't get any async errors 1125 // make sure that we don't get any async errors
1125 qApp->flushX(); 1126 qApp->flushX();
1126 execute_command(_ifaceppp->data()->command_on_connect()); 1127 execute_command(_ifaceppp->data()->command_on_connect());
1127 messg->setText(QObject::tr("Done")); 1128 messg->setText(QObject::tr("Done"));
1128 } 1129 }
1129 1130
1130 // remove the authentication file 1131 // remove the authentication file
1131 _ifaceppp->modem()->removeSecret(AUTH_PAP); 1132 _ifaceppp->modem()->removeSecret(AUTH_PAP);
1132 _ifaceppp->modem()->removeSecret(AUTH_CHAP); 1133 _ifaceppp->modem()->removeSecret(AUTH_CHAP);
1133 1134
1134 emit debugMessage(QObject::tr("Done")); 1135 emit debugMessage(QObject::tr("Done"));
1135 set_con_speed_string(); 1136 set_con_speed_string();
1136 1137
1137// p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed); 1138// p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed);
1138// this->hide(); 1139// this->hide();
1139// messg->setText(""); 1140// messg->setText("");
1140 1141
1141 _ifaceppp->setStatus( true ); 1142 _ifaceppp->setStatus( true );
1142 1143
1143 m_refreshTimer = new QTimer( this ); 1144 m_refreshTimer = new QTimer( this );
1144 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 1145 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
1145 m_refreshTimer->start( 3000 ); 1146 m_refreshTimer->start( 3000 );
1146 //_ifaceppp->refresh(); 1147 //_ifaceppp->refresh();
1147 // emit _ifaceppp->updateInterface(_ifaceppp); 1148 // emit _ifaceppp->updateInterface(_ifaceppp);
1148 1149
1149 // prepare the con_win so as to have the right size for 1150 // prepare the con_win so as to have the right size for
1150 // accounting / non-accounting mode 1151 // accounting / non-accounting mode
1151// if(p_kppp->acct != 0) 1152// if(p_kppp->acct != 0)
1152// p_kppp->con_win->accounting(p_kppp->acct->running()); 1153// p_kppp->con_win->accounting(p_kppp->acct->running());
1153// else 1154// else
1154// p_kppp->con_win->accounting(false); 1155// p_kppp->con_win->accounting(false);
1155 1156
1156// if (_ifaceppp->data()->get_dock_into_panel()) { 1157// if (_ifaceppp->data()->get_dock_into_panel()) {
1157// // DockWidget::dock_widget->show(); 1158// // DockWidget::dock_widget->show();
1158// // DockWidget::dock_widget->take_stats(); 1159// // DockWidget::dock_widget->take_stats();
1159// // this->hide(); 1160// // this->hide();
1160// } 1161// }
1161// else { 1162// else {
1162// // p_kppp->con_win->show(); 1163// // p_kppp->con_win->show();
1163 1164
1164// if(_ifaceppp->data()->get_iconify_on_connect()) { 1165// if(_ifaceppp->data()->get_iconify_on_connect()) {
1165// // p_kppp->con_win->showMinimized(); 1166// // p_kppp->con_win->showMinimized();
1166// } 1167// }
1167// } 1168// }
1168 1169
1169 _ifaceppp->modem()->closetty(); 1170 _ifaceppp->modem()->closetty();
1170} 1171}
1171 1172
1172void ConnectWidget::refresh() { 1173void ConnectWidget::refresh() {
1173 _ifaceppp->refresh(); 1174 _ifaceppp->refresh();
1174 if ( _ifaceppp->getStatus() ) { 1175 if ( _ifaceppp->getStatus() ) {
1175 messg->setText(QObject::tr("Online")); 1176 messg->setText(QObject::tr("Online"));
1176 } else { 1177 } else {
1177 messg->setText(QObject::tr("Offline")); 1178 messg->setText(QObject::tr("Offline"));
1178 } 1179 }
1179} 1180}
1180 1181
1181 1182
1182bool ConnectWidget::execppp() { 1183bool ConnectWidget::execppp() {
1183 QString command; 1184 QString command;
1184 1185
1185 command = "pppd"; 1186 command = "pppd";
1186 1187
1187 // as of version 2.3.6 pppd falls back to the real user rights when 1188 // as of version 2.3.6 pppd falls back to the real user rights when
1188 // opening a device given in a command line. To avoid permission conflicts 1189 // opening a device given in a command line. To avoid permission conflicts
1189 // we'll simply leave this argument away. pppd will then use the default tty 1190 // we'll simply leave this argument away. pppd will then use the default tty
1190 // which is the serial port we connected stdin/stdout to in opener.cpp. 1191 // which is the serial port we connected stdin/stdout to in opener.cpp.
1191 // command += " "; 1192 // command += " ";
1192 // command += _ifaceppp->data()->modemDevice(); 1193 // command += _ifaceppp->data()->modemDevice();
1193 1194
1194 command += " " + _ifaceppp->data()->speed(); 1195 command += " " + _ifaceppp->data()->speed();
1195 1196
1196 command += " -detach"; 1197 command += " -detach";
1197 1198
1198 if(_ifaceppp->data()->ipaddr() != "0.0.0.0" || 1199 if(_ifaceppp->data()->ipaddr() != "0.0.0.0" ||
1199 _ifaceppp->data()->gateway() != "0.0.0.0") { 1200 _ifaceppp->data()->gateway() != "0.0.0.0") {
1200 if(_ifaceppp->data()->ipaddr() != "0.0.0.0") { 1201 if(_ifaceppp->data()->ipaddr() != "0.0.0.0") {
1201 command += " "; 1202 command += " ";
1202 command += _ifaceppp->data()->ipaddr(); 1203 command += _ifaceppp->data()->ipaddr();
1203 command += ":"; 1204 command += ":";
1204 } 1205 }
1205 else { 1206 else {
1206 command += " "; 1207 command += " ";
1207 command += ":"; 1208 command += ":";
1208 } 1209 }
1209 1210
1210 if(_ifaceppp->data()->gateway() != "0.0.0.0") 1211 if(_ifaceppp->data()->gateway() != "0.0.0.0")
1211 command += _ifaceppp->data()->gateway(); 1212 command += _ifaceppp->data()->gateway();
1212 } 1213 }
1213 1214
1214 if(_ifaceppp->data()->subnetmask() != "0.0.0.0") 1215 if(_ifaceppp->data()->subnetmask() != "0.0.0.0")
1215 command += " netmask " + _ifaceppp->data()->subnetmask(); 1216 command += " netmask " + _ifaceppp->data()->subnetmask();
1216 1217
1217 if(_ifaceppp->data()->flowcontrol() != "None") { 1218 if(_ifaceppp->data()->flowcontrol() != "None") {
1218 if(_ifaceppp->data()->flowcontrol() == "CRTSCTS") 1219 if(_ifaceppp->data()->flowcontrol() == "CRTSCTS")
1219 command += " crtscts"; 1220 command += " crtscts";
1220 else 1221 else
1221 command += " xonxoff"; 1222 command += " xonxoff";
1222 } 1223 }
1223 1224
1224 if(_ifaceppp->data()->defaultroute()) 1225 if(_ifaceppp->data()->defaultroute())
1225 command += " defaultroute"; 1226 command += " defaultroute";
1226 1227
1227 if(_ifaceppp->data()->autoDNS()) 1228 if(_ifaceppp->data()->autoDNS())
1228 command += " usepeerdns"; 1229 command += " usepeerdns";
1229 1230
1230 1231
1231 // PAP settings 1232 // PAP settings
1232 if(_ifaceppp->data()->authMethod() == AUTH_PAP) { 1233 if(_ifaceppp->data()->authMethod() == AUTH_PAP) {
1233 command += " -chap user "; 1234 command += " -chap user ";
1234 command = command + _ifaceppp->data()->storedUsername(); 1235 command = command + _ifaceppp->data()->storedUsername();
1235 } 1236 }
1236 1237
1237 // CHAP settings 1238 // CHAP settings
1238 if(_ifaceppp->data()->authMethod() == AUTH_CHAP) { 1239 if(_ifaceppp->data()->authMethod() == AUTH_CHAP) {
1239 command += " -pap user "; 1240 command += " -pap user ";
1240 command = command + _ifaceppp->data()->storedUsername(); 1241 command = command + _ifaceppp->data()->storedUsername();
1241 } 1242 }
1242 1243
1243 // PAP/CHAP settings 1244 // PAP/CHAP settings
1244 if(_ifaceppp->data()->authMethod() == AUTH_PAPCHAP) { 1245 if(_ifaceppp->data()->authMethod() == AUTH_PAPCHAP) {
1245 QString tmpName = _ifaceppp->data()->storedUsername(); 1246 QString tmpName = _ifaceppp->data()->storedUsername();
1246 if ( !tmpName.isEmpty() ) { 1247 if ( !tmpName.isEmpty() ) {
1247 command += " user "; 1248 command += " user ";
1248 command = command + tmpName; 1249 command = command + tmpName;
1249 } 1250 }
1250 } 1251 }
1251 1252
1252 // check for debug 1253 // check for debug
1253 if(_ifaceppp->data()->getPPPDebug()) 1254 if(_ifaceppp->data()->getPPPDebug())
1254 command += " debug"; 1255 command += " debug";
1255 1256
1256 QStringList &arglist = _ifaceppp->data()->pppdArgument(); 1257 QStringList &arglist = _ifaceppp->data()->pppdArgument();
1257 for ( QStringList::Iterator it = arglist.begin(); 1258 for ( QStringList::Iterator it = arglist.begin();
1258 it != arglist.end(); 1259 it != arglist.end();
1259 ++it ) 1260 ++it )
1260 { 1261 {
1261 command += " " + *it; 1262 command += " " + *it;
1262 } 1263 }
1263 1264
1264 command += " call opie-kppp logfd 11"; 1265 command += " call opie-kppp logfd 11";
1265 1266
1266 if (command.length() > MAX_CMDLEN) { 1267 if (command.length() > MAX_CMDLEN) {
1267 QMessageBox::critical(this, "error", QObject::tr( 1268 QMessageBox::critical(this, "error", QObject::tr(
1268 "pppd command + command-line arguments exceed " 1269 "pppd command + command-line arguments exceed "
1269 "2024 characters in length." 1270 "2024 characters in length."
1270 )); 1271 ));
1271 1272
1272 return false; // nonsensically long command which would bust my buffer buf. 1273 return false; // nonsensically long command which would bust my buffer buf.
1273 } 1274 }
1274 1275
1275 owarn << "Command IS: " << command.latin1() << "" << oendl; 1276 owarn << "Command IS: " << command.latin1() << "" << oendl;
1276 1277
1277 qApp->flushX(); 1278 qApp->flushX();
1278 1279
1279 return _ifaceppp->modem()->execPPPDaemon(command); 1280 return _ifaceppp->modem()->execPPPDaemon(command);
1280} 1281}
1281 1282
1282 1283
1283void ConnectWidget::closeEvent( QCloseEvent *e ) { 1284void ConnectWidget::closeEvent( QCloseEvent *e ) {
1284 e->ignore(); 1285 e->ignore();
1285 emit cancelbutton(); 1286 emit cancelbutton();
1286} 1287}
1287 1288
1288 1289
1289void ConnectWidget::setMsg(const QString &msg) { 1290void ConnectWidget::setMsg(const QString &msg) {
1290 messg->setText(msg); 1291 messg->setText(msg);
1291} 1292}
1292 1293
1293void ConnectWidget::writeline(const QString &s) { 1294void ConnectWidget::writeline(const QString &s) {
1294 _ifaceppp->modem()->writeLine(s.local8Bit()); 1295 _ifaceppp->modem()->writeLine(s.local8Bit());
1295} 1296}
1296 1297
1297// Set the hostname and domain from DNS Server 1298// Set the hostname and domain from DNS Server
1298void auto_hostname(InterfacePPP *_ifaceppp) { 1299void auto_hostname(InterfacePPP *_ifaceppp) {
1299 struct in_addr local_ip; 1300 struct in_addr local_ip;
1300 struct hostent *hostname_entry; 1301 struct hostent *hostname_entry;
1301 QString new_hostname; 1302 QString new_hostname;
1302 int dot; 1303 int dot;
1303 char tmp_str[100]; // buffer overflow safe 1304 char tmp_str[100]; // buffer overflow safe
1304 1305
1305 gethostname(tmp_str, sizeof(tmp_str)); 1306 gethostname(tmp_str, sizeof(tmp_str));
1306 tmp_str[sizeof(tmp_str)-1]=0; // panic 1307 tmp_str[sizeof(tmp_str)-1]=0; // panic
1307 old_hostname=tmp_str; // copy to QString 1308 old_hostname=tmp_str; // copy to QString
1308 1309
1309 // if (!p_kppp->stats->local_ip_address.isEmpty() && _ifaceppp->data()->autoname()) { 1310 // if (!p_kppp->stats->local_ip_address.isEmpty() && _ifaceppp->data()->autoname()) {
1310 if ( _ifaceppp->data()->autoname()) { 1311 if ( _ifaceppp->data()->autoname()) {
1311// local_ip.s_addr=inet_addr(p_kppp->stats->local_ip_address.ascii()); 1312// local_ip.s_addr=inet_addr(p_kppp->stats->local_ip_address.ascii());
1312 hostname_entry=gethostbyaddr((const char *)&local_ip,sizeof(in_addr),AF_INET); 1313 hostname_entry=gethostbyaddr((const char *)&local_ip,sizeof(in_addr),AF_INET);
1313 1314
1314 if (hostname_entry != 0L) { 1315 if (hostname_entry != 0L) {
1315 new_hostname=hostname_entry->h_name; 1316 new_hostname=hostname_entry->h_name;
1316 dot=new_hostname.find('.'); 1317 dot=new_hostname.find('.');
1317 new_hostname=new_hostname.remove(dot,new_hostname.length()-dot); 1318 new_hostname=new_hostname.remove(dot,new_hostname.length()-dot);
1318 _ifaceppp->modem()->setHostname(new_hostname); 1319 _ifaceppp->modem()->setHostname(new_hostname);
1319 modified_hostname = TRUE; 1320 modified_hostname = TRUE;
1320 1321
1321 new_hostname=hostname_entry->h_name; 1322 new_hostname=hostname_entry->h_name;
1322 new_hostname.remove(0,dot+1); 1323 new_hostname.remove(0,dot+1);
1323 1324
1324 add_domain(new_hostname, _ifaceppp); 1325 add_domain(new_hostname, _ifaceppp);
1325 } 1326 }
1326 } 1327 }
1327 1328
1328} 1329}
1329 1330
1330// Replace the DNS domain entry in the /etc/resolv.conf file and 1331// Replace the DNS domain entry in the /etc/resolv.conf file and
1331// disable the nameserver entries if option is enabled 1332// disable the nameserver entries if option is enabled
1332void add_domain(const QString &domain, InterfacePPP *_ifaceppp) { 1333void add_domain(const QString &domain, InterfacePPP *_ifaceppp) {
1333 1334
1334 int fd; 1335 int fd;
1335 char c; 1336 char c;
1336 QString resolv[MAX_RESOLVCONF_LINES]; 1337 QString resolv[MAX_RESOLVCONF_LINES];
1337 1338
1338 if (domain.isEmpty()) 1339 if (domain.isEmpty())
1339 return; 1340 return;
1340 1341
1341 if((fd = _ifaceppp->modem()->openResolv(O_RDONLY)) >= 0) { 1342 if((fd = _ifaceppp->modem()->openResolv(O_RDONLY)) >= 0) {
1342 1343
1343 int i=0; 1344 int i=0;
1344 while((read(fd, &c, 1) == 1) && (i < MAX_RESOLVCONF_LINES)) { 1345 while((read(fd, &c, 1) == 1) && (i < MAX_RESOLVCONF_LINES)) {
1345 if(c == '\n') { 1346 if(c == '\n') {
1346 i++; 1347 i++;
1347 } 1348 }
1348 else { 1349 else {
1349 resolv[i] += c; 1350 resolv[i] += c;
1350 } 1351 }
1351 } 1352 }
1352 close(fd); 1353 close(fd);
1353 if ((c != '\n') && (i < MAX_RESOLVCONF_LINES)) i++; 1354 if ((c != '\n') && (i < MAX_RESOLVCONF_LINES)) i++;
1354 1355
1355 if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_TRUNC)) >= 0) { 1356 if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_TRUNC)) >= 0) {
1356 QCString tmp = "domain " + domain.local8Bit() + 1357 QCString tmp = "domain " + domain.local8Bit() +
1357 " \t\t#kppp temp entry\n"; 1358 " \t\t#kppp temp entry\n";
1358 write(fd, tmp.data(), tmp.length()); 1359 write(fd, tmp.data(), tmp.length());
1359 1360
1360 for(int j=0; j < i; j++) { 1361 for(int j=0; j < i; j++) {
1361 if((resolv[j].contains("domain") || 1362 if((resolv[j].contains("domain") ||
1362 ( resolv[j].contains("nameserver") 1363 ( resolv[j].contains("nameserver")
1363 && !resolv[j].contains("#kppp temp entry") 1364 && !resolv[j].contains("#kppp temp entry")
1364 && _ifaceppp->data()->exDNSDisabled())) 1365 && _ifaceppp->data()->exDNSDisabled()))
1365 && !resolv[j].contains("#entry disabled by kppp")) { 1366 && !resolv[j].contains("#entry disabled by kppp")) {
1366 QCString tmp = "# " + resolv[j].local8Bit() + 1367 QCString tmp = "# " + resolv[j].local8Bit() +
1367 " \t#entry disabled by kppp\n"; 1368 " \t#entry disabled by kppp\n";
1368 write(fd, tmp, tmp.length()); 1369 write(fd, tmp, tmp.length());
1369 } 1370 }
1370 else { 1371 else {
1371 QCString tmp = resolv[j].local8Bit() + "\n"; 1372 QCString tmp = resolv[j].local8Bit() + "\n";
1372 write(fd, tmp, tmp.length()); 1373 write(fd, tmp, tmp.length());
1373 } 1374 }
1374 } 1375 }
1375 } 1376 }
1376 close(fd); 1377 close(fd);
1377 } 1378 }
1378} 1379}
1379 1380
1380 1381
1381// adds the DNS entries in the /etc/resolv.conf file 1382// adds the DNS entries in the /etc/resolv.conf file
1382void adddns( InterfacePPP *_ifaceppp) 1383void adddns( InterfacePPP *_ifaceppp)
1383{ 1384{
1384 int fd; 1385 int fd;
1385 1386
1386 if ((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_APPEND)) >= 0) { 1387 if ((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_APPEND)) >= 0) {
1387 QStringList &dnslist = _ifaceppp->data()->dns(); 1388 QStringList &dnslist = _ifaceppp->data()->dns();
1388 for ( QStringList::Iterator it = dnslist.begin(); 1389 for ( QStringList::Iterator it = dnslist.begin();
1389 it != dnslist.end(); 1390 it != dnslist.end();
1390 ++it ) 1391 ++it )
1391 { 1392 {
1392 QCString dns = "nameserver " + (*it).local8Bit() + 1393 QCString dns = "nameserver " + (*it).local8Bit() +
1393 " \t#kppp temp entry\n"; 1394 " \t#kppp temp entry\n";
1394 write(fd, dns.data(), dns.length()); 1395 write(fd, dns.data(), dns.length());
1395 } 1396 }
1396 close(fd); 1397 close(fd);
1397 } 1398 }
1398 add_domain(_ifaceppp->data()->domain(), _ifaceppp); 1399 add_domain(_ifaceppp->data()->domain(), _ifaceppp);
1399} 1400}
1400 1401
1401void addpeerdns(InterfacePPP *_ifaceppp) { 1402void addpeerdns(InterfacePPP *_ifaceppp) {
1402 int fd, fd2; 1403 int fd, fd2;
1403 1404
1404 if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_APPEND)) >= 0) { 1405 if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_APPEND)) >= 0) {
1405 if((fd2 = open("/etc/ppp/resolv.conf", O_RDONLY)) >= 0) { 1406 if((fd2 = open("/etc/ppp/resolv.conf", O_RDONLY)) >= 0) {
1406 char c; 1407 char c;
1407 int i = 0; 1408 int i = 0;
1408 while(i++ < 100 && read(fd2, &c, 1) == 1) { 1409 while(i++ < 100 && read(fd2, &c, 1) == 1) {
1409 if(c == '\n') 1410 if(c == '\n')
1410 write(fd, "\t#kppp temp entry\n", 18); 1411 write(fd, "\t#kppp temp entry\n", 18);
1411 else 1412 else
1412 write(fd, &c, 1); 1413 write(fd, &c, 1);
1413 } 1414 }
1414 close(fd2); 1415 close(fd2);
1415 } else 1416 } else
1416 fprintf(stderr, "failed to read from /etc/ppp/resolv.conf\n"); 1417 fprintf(stderr, "failed to read from /etc/ppp/resolv.conf\n");
1417 close(fd); 1418 close(fd);
1418 } 1419 }
1419 add_domain(_ifaceppp->data()->domain(), _ifaceppp); 1420 add_domain(_ifaceppp->data()->domain(), _ifaceppp);
1420} 1421}
1421 1422
1422// remove the dns entries from the /etc/resolv.conf file 1423// remove the dns entries from the /etc/resolv.conf file
1423void removedns(InterfacePPP *_ifaceppp) { 1424void removedns(InterfacePPP *_ifaceppp) {
1424 1425
1425 int fd; 1426 int fd;
1426 char c; 1427 char c;
1427 QString resolv[MAX_RESOLVCONF_LINES]; 1428 QString resolv[MAX_RESOLVCONF_LINES];
1428 1429
1429 if((fd = _ifaceppp->modem()->openResolv(O_RDONLY)) >= 0) { 1430 if((fd = _ifaceppp->modem()->openResolv(O_RDONLY)) >= 0) {
1430 1431
1431 int i=0; 1432 int i=0;
1432 while(read(fd, &c, 1) == 1 && i < MAX_RESOLVCONF_LINES) { 1433 while(read(fd, &c, 1) == 1 && i < MAX_RESOLVCONF_LINES) {
1433 if(c == '\n') { 1434 if(c == '\n') {
1434 i++; 1435 i++;
1435 } 1436 }
1436 else { 1437 else {
1437 resolv[i] += c; 1438 resolv[i] += c;
1438 } 1439 }
1439 } 1440 }
1440 close(fd); 1441 close(fd);
1441 1442
1442 if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_TRUNC)) >= 0) { 1443 if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_TRUNC)) >= 0) {
1443 for(int j=0; j < i; j++) { 1444 for(int j=0; j < i; j++) {
1444 if(resolv[j].contains("#kppp temp entry")) continue; 1445 if(resolv[j].contains("#kppp temp entry")) continue;
1445 if(resolv[j].contains("#entry disabled by kppp")) { 1446 if(resolv[j].contains("#entry disabled by kppp")) {
1446 QCString tmp = resolv[j].local8Bit(); 1447 QCString tmp = resolv[j].local8Bit();
1447 write(fd, tmp.data()+2, tmp.length() - 27); 1448 write(fd, tmp.data()+2, tmp.length() - 27);
1448 write(fd, "\n", 1); 1449 write(fd, "\n", 1);
1449 } 1450 }
1450 else { 1451 else {
1451 QCString tmp = resolv[j].local8Bit() + "\n"; 1452 QCString tmp = resolv[j].local8Bit() + "\n";
1452 write(fd, tmp, tmp.length()); 1453 write(fd, tmp, tmp.length());
1453 } 1454 }
1454 } 1455 }
1455 } 1456 }
1456 close(fd); 1457 close(fd);
1457 1458
1458 } 1459 }
1459 1460
1460 if ( modified_hostname ) { 1461 if ( modified_hostname ) {
1461 _ifaceppp->modem()->setHostname(old_hostname); 1462 _ifaceppp->modem()->setHostname(old_hostname);
1462 modified_hostname = FALSE; 1463 modified_hostname = FALSE;
1463 } 1464 }
1464 1465
1465} 1466}
1466 1467
1467 1468
diff --git a/noncore/settings/networksettings/ppp/devices.cpp b/noncore/settings/networksettings/ppp/devices.cpp
index 42de44c..e2c67d8 100644
--- a/noncore/settings/networksettings/ppp/devices.cpp
+++ b/noncore/settings/networksettings/ppp/devices.cpp
@@ -1,219 +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 <opie2/odebug.h>
36#include <qpe/qpeapplication.h> 36#include <qpe/qpeapplication.h>
37using namespace Opie::Core; 37using namespace Opie::Core;
38 38
39/* QT */ 39/* QT */
40#include <qdir.h> 40#include <qdir.h>
41#include <qlayout.h> 41#include <qlayout.h>
42#include <qtabwidget.h> 42#include <qtabwidget.h>
43#include <qtabdialog.h> 43#include <qtabdialog.h>
44#include <qwhatsthis.h> 44#include <qwhatsthis.h>
45#include <qmessagebox.h> 45#include <qmessagebox.h>
46#include <qapplication.h> 46#include <qapplication.h>
47#include <qbuttongroup.h> 47#include <qbuttongroup.h>
48#include <qmessagebox.h> 48#include <qmessagebox.h>
49#include <qvgroupbox.h> 49#include <qvgroupbox.h>
50 50
51/* STD */ 51/* STD */
52#include <stdlib.h> 52#include <stdlib.h>
53 53
54 54
55void parseargs(char* buf, char** args); 55void parseargs(char* buf, char** args);
56 56
57DevicesWidget::DevicesWidget( InterfacePPP* ip, QWidget *parent, const char *name, WFlags f ) 57DevicesWidget::DevicesWidget( InterfacePPP* ip, QWidget *parent, const char *name, WFlags f )
58 : ChooserWidget(ip->data(), parent, name, f) 58 : ChooserWidget(ip->data(), parent, name, f)
59{ 59{
60 _ifaceppp = ip; 60 _ifaceppp = ip;
61 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"));
62 QWhatsThis::add(new_b, tr("Create a new device") ); 62 QWhatsThis::add(new_b, tr("Create a new device") );
63 63
64 QWhatsThis::add(copy_b, 64 QWhatsThis::add(copy_b,
65 tr("Makes a copy of the selected device. All\n" 65 tr("Makes a copy of the selected device. All\n"
66 "settings of the selected device are copied\n" 66 "settings of the selected device are copied\n"
67 "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"
68 "needs")); 68 "needs"));
69 QWhatsThis::add(delete_b, 69 QWhatsThis::add(delete_b,
70 tr("<p>Deletes the selected device\n\n" 70 tr("<p>Deletes the selected device\n\n"
71 "<font color=\"red\"><b>Use with care!</b></font>")); 71 "<font color=\"red\"><b>Use with care!</b></font>"));
72 72
73 copy_b->setEnabled( false ); //FIXME 73 copy_b->setEnabled( false ); //FIXME
74// delete_b->setEnabled( false ); //FIXME 74// delete_b->setEnabled( false ); //FIXME
75 75
76 QStringList tmp = _pppdata->getDevicesNamesList(); 76 QStringList tmp = _pppdata->getDevicesNamesList();
77 odebug << "DevicesWidget::DevicesWidget got devices " << tmp.join("--").latin1() << "" << oendl; 77 odebug << "DevicesWidget::DevicesWidget got devices " << tmp.join("--").latin1() << "" << oendl;
78 listListbox->insertStringList(tmp); 78 listListbox->insertStringList(tmp);
79 79
80 for (uint i = 0; i < listListbox->count(); i++){ 80 for (uint i = 0; i < listListbox->count(); i++){
81 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;
82 if ( listListbox->text(i) == _pppdata->devname() ) 82 if ( listListbox->text(i) == _pppdata->devname() )
83 listListbox->setCurrentItem( i ); 83 listListbox->setCurrentItem( i );
84 } 84 }
85} 85}
86 86
87 87
88 88
89void DevicesWidget::slotListBoxSelect(int idx) { 89void DevicesWidget::slotListBoxSelect(int idx) {
90 bool ok = _pppdata->setDevice( listListbox->text(idx) ); 90 _pppdata->setDevice( listListbox->text(idx) );
91 delete_b->setEnabled((bool)(idx != -1)); 91 delete_b->setEnabled((bool)(idx != -1));
92 edit_b->setEnabled((bool)(idx != -1)); 92 edit_b->setEnabled((bool)(idx != -1));
93//FIXME copy_b->setEnabled((bool)(idx != -1)); 93//FIXME copy_b->setEnabled((bool)(idx != -1));
94} 94}
95 95
96void DevicesWidget::edit() { 96void DevicesWidget::edit() {
97 _pppdata->setDevice(listListbox->text(listListbox->currentItem())); 97 _pppdata->setDevice(listListbox->text(listListbox->currentItem()));
98 98
99 int result = doTab(); 99 int result = doTab();
100 100
101 if(result == QDialog::Accepted) { 101 if(result == QDialog::Accepted) {
102 listListbox->changeItem(_pppdata->devname(),listListbox->currentItem()); 102 listListbox->changeItem(_pppdata->devname(),listListbox->currentItem());
103 _pppdata->save(); 103 _pppdata->save();
104 } 104 }
105} 105}
106 106
107 107
108void DevicesWidget::create() { 108void DevicesWidget::create() {
109 109
110// if(listListbox->count() == MAX_ACCOUNTS) { 110// if(listListbox->count() == MAX_ACCOUNTS) {
111// QMessageBox::information(this, "sorry", 111// QMessageBox::information(this, "sorry",
112// tr("Maximum number of accounts reached.")); 112// tr("Maximum number of accounts reached."));
113// return; 113// return;
114// } 114// }
115 115
116 int result; 116 int result;
117 if (_pppdata->newdevice() == -1){ 117 if (_pppdata->newdevice() == -1){
118 return; 118 return;
119 } 119 }
120 result = doTab(); 120 result = doTab();
121 121
122 if(result == QDialog::Accepted) { 122 if(result == QDialog::Accepted) {
123 listListbox->insertItem(_pppdata->devname()); 123 listListbox->insertItem(_pppdata->devname());
124 listListbox->setSelected(listListbox->findItem(_pppdata->devname()),true ); 124 listListbox->setSelected(listListbox->findItem(_pppdata->devname()),true );
125 125
126 _pppdata->save(); 126 _pppdata->save();
127 } else 127 } else
128 _pppdata->deleteDevice(); 128 _pppdata->deleteDevice();
129} 129}
130 130
131 131
132void DevicesWidget::copy() { 132void DevicesWidget::copy() {
133// if(listListbox->count() == MAX_ACCOUNTS) { 133// if(listListbox->count() == MAX_ACCOUNTS) {
134// QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached.")); 134// QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached."));
135// return; 135// return;
136// } 136// }
137 137
138 if(listListbox->currentItem()<0) { 138 if(listListbox->currentItem()<0) {
139 QMessageBox::information(this, "sorry", tr("No devices selected.")); 139 QMessageBox::information(this, "sorry", tr("No devices selected."));
140 return; 140 return;
141 } 141 }
142 142
143 _pppdata->copydevice(listListbox->currentText()); 143 _pppdata->copydevice(listListbox->currentText());
144 144
145 listListbox->insertItem(_pppdata->devname()); 145 listListbox->insertItem(_pppdata->devname());
146 _pppdata->save(); 146 _pppdata->save();
147} 147}
148 148
149 149
150void DevicesWidget::remove() { 150void DevicesWidget::remove() {
151 151
152 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\"?")
153 .arg(listListbox->text(listListbox->currentItem())); 153 .arg(listListbox->text(listListbox->currentItem()));
154 154
155 if(QMessageBox::warning(this,tr("Confirm"),s, 155 if(QMessageBox::warning(this,tr("Confirm"),s,
156 QMessageBox::Yes,QMessageBox::No 156 QMessageBox::Yes,QMessageBox::No
157 ) != QMessageBox::Yes) 157 ) != QMessageBox::Yes)
158 return; 158 return;
159 159
160 if(_pppdata->deleteDevice(listListbox->text(listListbox->currentItem()))) 160 if(_pppdata->deleteDevice(listListbox->text(listListbox->currentItem())))
161 listListbox->removeItem(listListbox->currentItem()); 161 listListbox->removeItem(listListbox->currentItem());
162 162
163 163
164// _pppdata->save(); 164// _pppdata->save();
165 165
166 166
167 slotListBoxSelect(listListbox->currentItem()); 167 slotListBoxSelect(listListbox->currentItem());
168 168
169} 169}
170 170
171 171
172int DevicesWidget::doTab(){ 172int DevicesWidget::doTab(){
173 QDialog *dlg = new QDialog( 0, "newDevice", true, Qt::WStyle_ContextHelp ); 173 QDialog *dlg = new QDialog( 0, "newDevice", true, Qt::WStyle_ContextHelp );
174 QVBoxLayout *layout = new QVBoxLayout( dlg ); 174 QVBoxLayout *layout = new QVBoxLayout( dlg );
175 layout->setSpacing( 0 ); 175 layout->setSpacing( 0 );
176 layout->setMargin( 1 ); 176 layout->setMargin( 1 );
177 177
178 QTabWidget *tabWindow = new QTabWidget( dlg, "tabWindow" ); 178 QTabWidget *tabWindow = new QTabWidget( dlg, "tabWindow" );
179 layout->addWidget( tabWindow ); 179 layout->addWidget( tabWindow );
180 180
181 bool isnew; 181 bool isnew;
182 182
183 if(_pppdata->devname().isEmpty()) { 183 if(_pppdata->devname().isEmpty()) {
184 dlg->setCaption(tr("New Device")); 184 dlg->setCaption(tr("New Device"));
185 isnew = true; 185 isnew = true;
186 } else { 186 } else {
187 QString tit = tr("Edit Device: "); 187 QString tit = tr("Edit Device: ");
188 tit += _pppdata->devname(); 188 tit += _pppdata->devname();
189 dlg->setCaption(tit); 189 dlg->setCaption(tit);
190 isnew = false; 190 isnew = false;
191 } 191 }
192 192
193 modem1 = new ModemWidget( _pppdata, tabWindow, "modem1" ); 193 modem1 = new ModemWidget( _pppdata, tabWindow, "modem1" );
194 tabWindow->addTab( modem1, tr("&Device") ); 194 tabWindow->addTab( modem1, tr("&Device") );
195 modem2 = new ModemWidget2( _pppdata, _ifaceppp, tabWindow, "modem2" ); 195 modem2 = new ModemWidget2( _pppdata, _ifaceppp, tabWindow, "modem2" );
196 tabWindow->addTab( modem2, tr("&Modem") ); 196 tabWindow->addTab( modem2, tr("&Modem") );
197 197
198 int result = 0; 198 int result = 0;
199 bool ok = false; 199 bool ok = false;
200 200
201 while (!ok){ 201 while (!ok){
202 result = QPEApplication::execDialog( dlg ); 202 result = QPEApplication::execDialog( dlg );
203 ok = true; 203 ok = true;
204 204
205 if(result == QDialog::Accepted) { 205 if(result == QDialog::Accepted) {
206 if (!modem1->save()){ 206 if (!modem1->save()){
207 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"));
208 ok = false; 208 ok = false;
209 }else{ 209 }else{
210 modem2->save(); 210 modem2->save();
211 } 211 }
212 } 212 }
213 } 213 }
214 214
215 delete dlg; 215 delete dlg;
216 216
217 return result; 217 return result;
218} 218}
219 219
diff --git a/noncore/settings/networksettings/ppp/edit.cpp b/noncore/settings/networksettings/ppp/edit.cpp
index 3b2393c..6c9735c 100644
--- a/noncore/settings/networksettings/ppp/edit.cpp
+++ b/noncore/settings/networksettings/ppp/edit.cpp
@@ -437,775 +437,775 @@ IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char
437 "\n" 437 "\n"
438 "Don't enable this unless you really need it.")); 438 "Don't enable this unless you really need it."));
439 439
440 topLayout->addWidget(box); 440 topLayout->addWidget(box);
441 topLayout->addWidget(autoname); 441 topLayout->addWidget(autoname);
442 topLayout->addStretch(); 442 topLayout->addStretch();
443 443
444 //load info from gpppdata 444 //load info from gpppdata
445 if(!isnewaccount) 445 if(!isnewaccount)
446 { 446 {
447 if(_pppdata->ipaddr() == "0.0.0.0" && 447 if(_pppdata->ipaddr() == "0.0.0.0" &&
448 _pppdata->subnetmask() == "0.0.0.0") 448 _pppdata->subnetmask() == "0.0.0.0")
449 { 449 {
450 dynamicadd_rb->setChecked(true); 450 dynamicadd_rb->setChecked(true);
451 hitIPSelect(0); 451 hitIPSelect(0);
452 autoname->setChecked(_pppdata->autoname()); 452 autoname->setChecked(_pppdata->autoname());
453 } 453 }
454 else 454 else
455 { 455 {
456 ipaddress_l->setText(_pppdata->ipaddr()); 456 ipaddress_l->setText(_pppdata->ipaddr());
457 subnetmask_l->setText(_pppdata->subnetmask()); 457 subnetmask_l->setText(_pppdata->subnetmask());
458 staticadd_rb->setChecked(true); 458 staticadd_rb->setChecked(true);
459 autoname->setChecked(false); 459 autoname->setChecked(false);
460 } 460 }
461 } 461 }
462 else 462 else
463 { 463 {
464 dynamicadd_rb->setChecked(true); 464 dynamicadd_rb->setChecked(true);
465 hitIPSelect(0); 465 hitIPSelect(0);
466 } 466 }
467 467
468} 468}
469 469
470void IPWidget::autoname_t(bool on) 470void IPWidget::autoname_t(bool on)
471{ 471{
472 static bool was_warned = false; 472 static bool was_warned = false;
473 473
474 // big-fat warning when selecting the auto configure hostname option 474 // big-fat warning when selecting the auto configure hostname option
475 if(on && !was_warned) 475 if(on && !was_warned)
476 { 476 {
477 QMessageBox::information(this, 477 QMessageBox::information(this,
478 tr("Selecting this option might cause some weird " 478 tr("Selecting this option might cause some weird "
479 "problems with the X-server and applications " 479 "problems with the X-server and applications "
480 "while kppp is connected. Don't use it until " 480 "while kppp is connected. Don't use it until "
481 "you know what you are doing!\n" 481 "you know what you are doing!\n"
482 "For more information take a look at the " 482 "For more information take a look at the "
483 "handbook (or help) in the section \"Frequently " 483 "handbook (or help) in the section \"Frequently "
484 "asked questions\"."), 484 "asked questions\"."),
485 tr("Warning")); 485 tr("Warning"));
486 was_warned = true; 486 was_warned = true;
487 } 487 }
488} 488}
489 489
490 490
491void IPWidget::save() 491void IPWidget::save()
492{ 492{
493 if(dynamicadd_rb->isChecked()) 493 if(dynamicadd_rb->isChecked())
494 { 494 {
495 _pppdata->setIpaddr("0.0.0.0"); 495 _pppdata->setIpaddr("0.0.0.0");
496 _pppdata->setSubnetmask("0.0.0.0"); 496 _pppdata->setSubnetmask("0.0.0.0");
497 } 497 }
498 else 498 else
499 { 499 {
500 _pppdata->setIpaddr(ipaddress_l->text()); 500 _pppdata->setIpaddr(ipaddress_l->text());
501 _pppdata->setSubnetmask(subnetmask_l->text()); 501 _pppdata->setSubnetmask(subnetmask_l->text());
502 } 502 }
503 _pppdata->setAutoname(autoname->isChecked()); 503 _pppdata->setAutoname(autoname->isChecked());
504} 504}
505 505
506 506
507void IPWidget::hitIPSelect( int i ) 507void IPWidget::hitIPSelect( int i )
508{ 508{
509 if(i == 0) 509 if(i == 0)
510 { 510 {
511 ipaddress_label->setEnabled(false); 511 ipaddress_label->setEnabled(false);
512 sub_label->setEnabled(false); 512 sub_label->setEnabled(false);
513 ipaddress_l->setEnabled(false); 513 ipaddress_l->setEnabled(false);
514 subnetmask_l->setEnabled(false); 514 subnetmask_l->setEnabled(false);
515 } 515 }
516 else 516 else
517 { 517 {
518 ipaddress_label->setEnabled(true); 518 ipaddress_label->setEnabled(true);
519 sub_label->setEnabled(true); 519 sub_label->setEnabled(true);
520 ipaddress_l->setEnabled(true); 520 ipaddress_l->setEnabled(true);
521 subnetmask_l->setEnabled(true); 521 subnetmask_l->setEnabled(true);
522 } 522 }
523} 523}
524 524
525 525
526 526
527DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) 527DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name )
528 : QWidget(parent, name), _pppdata(pd) 528 : QWidget(parent, name), _pppdata(pd)
529{ 529{
530 QGridLayout *tl = new QGridLayout(this, 7, 2, 0 ); 530 QGridLayout *tl = new QGridLayout(this, 7, 2, 0 );
531 531
532 dnsdomain_label = new QLabel(tr("Domain name:"), this); 532 dnsdomain_label = new QLabel(tr("Domain name:"), this);
533 tl->addWidget(dnsdomain_label, 0, 0); 533 tl->addWidget(dnsdomain_label, 0, 0);
534 534
535 dnsdomain = new QLineEdit(this); 535 dnsdomain = new QLineEdit(this);
536 536
537 tl->addWidget(dnsdomain, 0, 1); 537 tl->addWidget(dnsdomain, 0, 1);
538 QString tmp = tr("If you enter a domain name here, this domain\n" 538 QString tmp = tr("If you enter a domain name here, this domain\n"
539 "name is used for your computer while you are\n" 539 "name is used for your computer while you are\n"
540 "connected. When the connection is closed, the\n" 540 "connected. When the connection is closed, the\n"
541 "original domain name of your computer is\n" 541 "original domain name of your computer is\n"
542 "restored.\n" 542 "restored.\n"
543 "\n" 543 "\n"
544 "If you leave this field blank, no changes are\n" 544 "If you leave this field blank, no changes are\n"
545 "made to the domain name."); 545 "made to the domain name.");
546 546
547 QWhatsThis::add(dnsdomain_label,tmp); 547 QWhatsThis::add(dnsdomain_label,tmp);
548 QWhatsThis::add(dnsdomain,tmp); 548 QWhatsThis::add(dnsdomain,tmp);
549 549
550 conf_label = new QLabel(tr("Configuration:"), this); 550 conf_label = new QLabel(tr("Configuration:"), this);
551 tl->addWidget(conf_label, 1, 0); 551 tl->addWidget(conf_label, 1, 0);
552 552
553 bg = new QButtonGroup("Group", this); 553 bg = new QButtonGroup("Group", this);
554 connect(bg, SIGNAL(clicked(int)), SLOT(DNS_Mode_Selected(int))); 554 connect(bg, SIGNAL(clicked(int)), SLOT(DNS_Mode_Selected(int)));
555 bg->hide(); 555 bg->hide();
556 556
557 autodns = new QRadioButton(tr("Automatic"), this); 557 autodns = new QRadioButton(tr("Automatic"), this);
558 bg->insert(autodns, 0); 558 bg->insert(autodns, 0);
559 tl->addWidget(autodns, 1, 1); 559 tl->addWidget(autodns, 1, 1);
560 if(!_pppdata->pppdVersionMin(2, 3, 7)) 560 if(!_pppdata->pppdVersionMin(2, 3, 7))
561 autodns->setEnabled(false); 561 autodns->setEnabled(false);
562 562
563 mandns = new QRadioButton(tr("Manual"), this); 563 mandns = new QRadioButton(tr("Manual"), this);
564 bg->insert(mandns, 1); 564 bg->insert(mandns, 1);
565 tl->addWidget(mandns, 2, 1); 565 tl->addWidget(mandns, 2, 1);
566 566
567 dns_label = new QLabel(tr("DNS IP address:"), this); 567 dns_label = new QLabel(tr("DNS IP address:"), this);
568 tl->addWidget(dns_label, 3, 0); 568 tl->addWidget(dns_label, 3, 0);
569 569
570 QHBoxLayout *l2 = new QHBoxLayout; 570 QHBoxLayout *l2 = new QHBoxLayout;
571 tl->addLayout(l2, 3, 1); 571 tl->addLayout(l2, 3, 1);
572 dnsipaddr = new IPLineEdit(this); 572 dnsipaddr = new IPLineEdit(this);
573 connect(dnsipaddr, SIGNAL(returnPressed()), 573 connect(dnsipaddr, SIGNAL(returnPressed()),
574 SLOT(adddns())); 574 SLOT(adddns()));
575 connect(dnsipaddr, SIGNAL(textChanged(const QString&)), 575 connect(dnsipaddr, SIGNAL(textChanged(const QString&)),
576 SLOT(DNS_Edit_Changed(const QString&))); 576 SLOT(DNS_Edit_Changed(const QString&)));
577 l2->addWidget(dnsipaddr, 1); 577 l2->addWidget(dnsipaddr, 1);
578 l2->addStretch(1); 578 l2->addStretch(1);
579 tmp = tr("<p>Allows you to specify a new DNS server to be\n" 579 tmp = tr("<p>Allows you to specify a new DNS server to be\n"
580 "used while you are connected. When the\n" 580 "used while you are connected. When the\n"
581 "connection is closed, this DNS entry will be\n" 581 "connection is closed, this DNS entry will be\n"
582 "removed again.\n" 582 "removed again.\n"
583 "\n" 583 "\n"
584 "To add a DNS server, type in the IP address of\n" 584 "To add a DNS server, type in the IP address of\n"
585 "the DNS server here and click on <b>Add</b>"); 585 "the DNS server here and click on <b>Add</b>");
586 586
587 QWhatsThis::add(dns_label, tmp); 587 QWhatsThis::add(dns_label, tmp);
588 QWhatsThis::add(dnsipaddr, tmp); 588 QWhatsThis::add(dnsipaddr, tmp);
589 589
590 QHBoxLayout *l1 = new QHBoxLayout; 590 QHBoxLayout *l1 = new QHBoxLayout;
591 tl->addLayout(l1, 4, 1); 591 tl->addLayout(l1, 4, 1);
592 add = new QPushButton(tr("Add"), this); 592 add = new QPushButton(tr("Add"), this);
593 connect(add, SIGNAL(clicked()), SLOT(adddns())); 593 connect(add, SIGNAL(clicked()), SLOT(adddns()));
594 l1->addWidget(add); 594 l1->addWidget(add);
595 // l1->addStretch(1); 595 // l1->addStretch(1);
596 QWhatsThis::add(add, 596 QWhatsThis::add(add,
597 tr("Click this button to add the DNS server\n" 597 tr("Click this button to add the DNS server\n"
598 "specified in the field above. The entry\n" 598 "specified in the field above. The entry\n"
599 "will then be added to the list below")); 599 "will then be added to the list below"));
600 600
601 remove = new QPushButton(tr("Remove"), this); 601 remove = new QPushButton(tr("Remove"), this);
602 connect(remove, SIGNAL(clicked()), SLOT(removedns())); 602 connect(remove, SIGNAL(clicked()), SLOT(removedns()));
603 l1->addWidget(remove); 603 l1->addWidget(remove);
604 QWhatsThis::add(remove, 604 QWhatsThis::add(remove,
605 tr("Click this button to remove the selected DNS\n" 605 tr("Click this button to remove the selected DNS\n"
606 "server entry from the list below")); 606 "server entry from the list below"));
607 607
608 servers_label = new QLabel(tr("DNS address list:"), this); 608 servers_label = new QLabel(tr("DNS address list:"), this);
609 servers_label->setAlignment(AlignTop|AlignLeft); 609 servers_label->setAlignment(AlignTop|AlignLeft);
610 tl->addWidget(servers_label, 5, 0); 610 tl->addWidget(servers_label, 5, 0);
611 611
612 dnsservers = new QListBox(this); 612 dnsservers = new QListBox(this);
613 dnsservers->setMinimumSize(150, 80); 613 dnsservers->setMinimumSize(150, 80);
614 connect(dnsservers, SIGNAL(highlighted(int)), 614 connect(dnsservers, SIGNAL(highlighted(int)),
615 SLOT(DNS_Entry_Selected(int))); 615 SLOT(DNS_Entry_Selected(int)));
616 tl->addWidget(dnsservers, 5, 1); 616 tl->addWidget(dnsservers, 5, 1);
617 tmp = tr("<p>This shows all defined DNS servers to use\n" 617 tmp = tr("<p>This shows all defined DNS servers to use\n"
618 "while you are connected. Use the <b>Add</b> and\n" 618 "while you are connected. Use the <b>Add</b> and\n"
619 "<b>Remove</b> buttons to modify the list"); 619 "<b>Remove</b> buttons to modify the list");
620 620
621 QWhatsThis::add(servers_label,tmp); 621 QWhatsThis::add(servers_label,tmp);
622 QWhatsThis::add(dnsservers,tmp); 622 QWhatsThis::add(dnsservers,tmp);
623 623
624 exdnsdisabled_toggle = new QCheckBox(tr("Disable DNS servers during connection"), this); 624 exdnsdisabled_toggle = new QCheckBox(tr("Disable DNS servers during connection"), this);
625 // exdnsdisabled_toggle = new QCheckBox(tr("Disable existing DNS servers during connection"), this); 625 // exdnsdisabled_toggle = new QCheckBox(tr("Disable existing DNS servers during connection"), this);
626 exdnsdisabled_toggle->setChecked(_pppdata->exDNSDisabled()); 626 exdnsdisabled_toggle->setChecked(_pppdata->exDNSDisabled());
627 tl->addMultiCellWidget(exdnsdisabled_toggle, 6, 6, 0, 1, AlignCenter); 627 tl->addMultiCellWidget(exdnsdisabled_toggle, 6, 6, 0, 1, AlignCenter);
628 QWhatsThis::add(exdnsdisabled_toggle, 628 QWhatsThis::add(exdnsdisabled_toggle,
629 tr("<p>When this option is selected, all DNS\n" 629 tr("<p>When this option is selected, all DNS\n"
630 "servers specified in <tt>/etc/resolv.conf</tt> are\n" 630 "servers specified in <tt>/etc/resolv.conf</tt> are\n"
631 "temporary disabled while the dialup connection\n" 631 "temporary disabled while the dialup connection\n"
632 "is established. After the connection is\n" 632 "is established. After the connection is\n"
633 "closed, the servers will be re-enabled\n" 633 "closed, the servers will be re-enabled\n"
634 "\n" 634 "\n"
635 "Typically, there is no reason to use this\n" 635 "Typically, there is no reason to use this\n"
636 "option, but it may become useful under \n" 636 "option, but it may become useful under \n"
637 "some circumstances.")); 637 "some circumstances."));
638 638
639 639
640 // restore data if editing 640 // restore data if editing
641 if(!isnewaccount) 641 if(!isnewaccount)
642 { 642 {
643 dnsservers->insertStringList(_pppdata->dns()); 643 dnsservers->insertStringList(_pppdata->dns());
644 dnsdomain->setText(_pppdata->domain()); 644 dnsdomain->setText(_pppdata->domain());
645 } 645 }
646 646
647 int mode = _pppdata->autoDNS() ? 0 : 1; 647 int mode = _pppdata->autoDNS() ? 0 : 1;
648 bg->setButton(mode); 648 bg->setButton(mode);
649 DNS_Mode_Selected(mode); 649 DNS_Mode_Selected(mode);
650 650
651 tl->activate(); 651 tl->activate();
652} 652}
653 653
654void DNSWidget::DNS_Edit_Changed(const QString &text) 654void DNSWidget::DNS_Edit_Changed(const QString &text)
655{ 655{
656 QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"); 656 QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+");
657 add->setEnabled(text.find(r) != -1); 657 add->setEnabled(text.find(r) != -1);
658} 658}
659 659
660void DNSWidget::DNS_Entry_Selected(int) 660void DNSWidget::DNS_Entry_Selected(int)
661{ 661{
662 remove->setEnabled(true); 662 remove->setEnabled(true);
663} 663}
664 664
665void DNSWidget::DNS_Mode_Selected(int mode) 665void DNSWidget::DNS_Mode_Selected(int mode)
666{ 666{
667 bool on = (mode == 1); 667 bool on = (mode == 1);
668 dns_label->setEnabled(on); 668 dns_label->setEnabled(on);
669 servers_label->setEnabled(on); 669 servers_label->setEnabled(on);
670 dnsipaddr->setText(""); 670 dnsipaddr->setText("");
671 dnsipaddr->setEnabled(on); 671 dnsipaddr->setEnabled(on);
672 add->setEnabled(false); 672 add->setEnabled(false);
673 remove->setEnabled(dnsservers->count()>0 && on); 673 remove->setEnabled(dnsservers->count()>0 && on);
674 dnsservers->clearSelection(); 674 dnsservers->clearSelection();
675 dnsservers->setEnabled(on); 675 dnsservers->setEnabled(on);
676 dnsservers->triggerUpdate(false); 676 dnsservers->triggerUpdate(false);
677} 677}
678 678
679void DNSWidget::save() 679void DNSWidget::save()
680{ 680{
681 _pppdata->setAutoDNS(bg->id(bg->selected()) == 0); 681 _pppdata->setAutoDNS(bg->id(bg->selected()) == 0);
682 QStringList serverlist; 682 QStringList serverlist;
683 for(uint i=0; i < dnsservers->count(); i++) 683 for(uint i=0; i < dnsservers->count(); i++)
684 serverlist.append(dnsservers->text(i)); 684 serverlist.append(dnsservers->text(i));
685 _pppdata->setDns(serverlist); 685 _pppdata->setDns(serverlist);
686 686
687 // strip leading dot 687 // strip leading dot
688 QString s(dnsdomain->text()); 688 QString s(dnsdomain->text());
689 if(s.left(1) == ".") 689 if(s.left(1) == ".")
690 _pppdata->setDomain(s.mid(1)); 690 _pppdata->setDomain(s.mid(1));
691 else 691 else
692 _pppdata->setDomain(dnsdomain->text()); 692 _pppdata->setDomain(dnsdomain->text());
693 693
694 _pppdata->setExDNSDisabled(exdnsdisabled_toggle->isChecked()); 694 _pppdata->setExDNSDisabled(exdnsdisabled_toggle->isChecked());
695} 695}
696 696
697 697
698void DNSWidget::adddns() 698void DNSWidget::adddns()
699{ 699{
700 if(dnsservers->count() < MAX_DNS_ENTRIES) 700 if(dnsservers->count() < MAX_DNS_ENTRIES)
701 { 701 {
702 dnsservers->insertItem(dnsipaddr->text()); 702 dnsservers->insertItem(dnsipaddr->text());
703 dnsipaddr->setText(""); 703 dnsipaddr->setText("");
704 } 704 }
705} 705}
706 706
707 707
708void DNSWidget::removedns() 708void DNSWidget::removedns()
709{ 709{
710 int i; 710 int i;
711 i = dnsservers->currentItem(); 711 i = dnsservers->currentItem();
712 if(i != -1) 712 if(i != -1)
713 dnsservers->removeItem(i); 713 dnsservers->removeItem(i);
714 remove->setEnabled(dnsservers->count()>0); 714 remove->setEnabled(dnsservers->count()>0);
715} 715}
716 716
717 717
718// 718//
719// GatewayWidget 719// GatewayWidget
720// 720//
721GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) 721GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name )
722 : QWidget(parent, name), _pppdata(pd) 722 : QWidget(parent, name), _pppdata(pd)
723{ 723{
724 QVBoxLayout *topLayout = new QVBoxLayout(this); 724 QVBoxLayout *topLayout = new QVBoxLayout(this);
725 topLayout->setSpacing( 2 ); 725 topLayout->setSpacing( 2 );
726 topLayout->setMargin( 0 ); 726 topLayout->setMargin( 0 );
727 727
728 box = new QVGroupBox(tr("Configuration"), this); 728 box = new QVGroupBox(tr("Configuration"), this);
729 729
730 rb = new QButtonGroup(this); 730 rb = new QButtonGroup(this);
731 rb->hide(); 731 rb->hide();
732 connect(rb, SIGNAL(clicked(int)), SLOT(hitGatewaySelect(int))); 732 connect(rb, SIGNAL(clicked(int)), SLOT(hitGatewaySelect(int)));
733 733
734 defaultgateway = new QRadioButton(box); 734 defaultgateway = new QRadioButton(box);
735 defaultgateway->setText(tr("Default gateway")); 735 defaultgateway->setText(tr("Default gateway"));
736 rb->insert(defaultgateway, 0); 736 rb->insert(defaultgateway, 0);
737 QWhatsThis::add(defaultgateway, 737 QWhatsThis::add(defaultgateway,
738 tr("This makes the PPP peer computer (the computer\n" 738 tr("This makes the PPP peer computer (the computer\n"
739 "you are connected to with your modem) to act as\n" 739 "you are connected to with your modem) to act as\n"
740 "a gateway. Your computer will send all packets not\n" 740 "a gateway. Your computer will send all packets not\n"
741 "going to a computer inside your local net to this\n" 741 "going to a computer inside your local net to this\n"
742 "computer, which will route these packets.\n" 742 "computer, which will route these packets.\n"
743 "\n" 743 "\n"
744 "This is the default for most ISPs, so you should\n" 744 "This is the default for most ISPs, so you should\n"
745 "probably leave this option on.")); 745 "probably leave this option on."));
746 746
747 747
748 staticgateway = new QRadioButton(box); 748 staticgateway = new QRadioButton(box);
749 staticgateway->setText(tr("Static gateway")); 749 staticgateway->setText(tr("Static gateway"));
750 rb->insert(staticgateway, 1); 750 rb->insert(staticgateway, 1);
751 QWhatsThis::add(staticgateway, 751 QWhatsThis::add(staticgateway,
752 tr("<p>Allows you to specify which computer you want\n" 752 tr("<p>Allows you to specify which computer you want\n"
753 "to use as gateway (see <i>Default Gateway</i> above)")); 753 "to use as gateway (see <i>Default Gateway</i> above)"));
754 754
755 QHBox *gateBox = new QHBox(box); 755 QHBox *gateBox = new QHBox(box);
756 gate_label = new QLabel(tr("Gateway IP address:"), gateBox); 756 gate_label = new QLabel(tr("Gateway IP address:"), gateBox);
757 gatewayaddr = new IPLineEdit(gateBox); 757 gatewayaddr = new IPLineEdit(gateBox);
758 758
759 defaultroute = new QCheckBox(tr("Assign the default route to this gateway"), 759 defaultroute = new QCheckBox(tr("Assign the default route to this gateway"),
760 this); 760 this);
761 QWhatsThis::add(defaultroute, 761 QWhatsThis::add(defaultroute,
762 tr("If this option is enabled, all packets not\n" 762 tr("If this option is enabled, all packets not\n"
763 "going to the local net are routed through\n" 763 "going to the local net are routed through\n"
764 "the PPP connection.\n" 764 "the PPP connection.\n"
765 "\n" 765 "\n"
766 "Normally, you should turn this on")); 766 "Normally, you should turn this on"));
767 767
768 topLayout->addWidget(box); 768 topLayout->addWidget(box);
769 topLayout->addWidget(defaultroute); 769 topLayout->addWidget(defaultroute);
770 topLayout->addStretch(); 770 topLayout->addStretch();
771 771
772 //load info from gpppdata 772 //load info from gpppdata
773 if(!isnewaccount) 773 if(!isnewaccount)
774 { 774 {
775 if(_pppdata->gateway() == "0.0.0.0") 775 if(_pppdata->gateway() == "0.0.0.0")
776 { 776 {
777 defaultgateway->setChecked(true); 777 defaultgateway->setChecked(true);
778 hitGatewaySelect(0); 778 hitGatewaySelect(0);
779 } 779 }
780 else 780 else
781 { 781 {
782 gatewayaddr->setText(_pppdata->gateway()); 782 gatewayaddr->setText(_pppdata->gateway());
783 staticgateway->setChecked(true); 783 staticgateway->setChecked(true);
784 } 784 }
785 defaultroute->setChecked(_pppdata->defaultroute()); 785 defaultroute->setChecked(_pppdata->defaultroute());
786 } 786 }
787 else 787 else
788 { 788 {
789 defaultgateway->setChecked(true); 789 defaultgateway->setChecked(true);
790 hitGatewaySelect(0); 790 hitGatewaySelect(0);
791 defaultroute->setChecked(true); 791 defaultroute->setChecked(true);
792 } 792 }
793} 793}
794 794
795void GatewayWidget::save() 795void GatewayWidget::save()
796{ 796{
797 _pppdata->setGateway(gatewayaddr->text()); 797 _pppdata->setGateway(gatewayaddr->text());
798 _pppdata->setDefaultroute(defaultroute->isChecked()); 798 _pppdata->setDefaultroute(defaultroute->isChecked());
799} 799}
800 800
801 801
802void GatewayWidget::hitGatewaySelect( int i ) 802void GatewayWidget::hitGatewaySelect( int i )
803{ 803{
804 if(i == 0) 804 if(i == 0)
805 { 805 {
806 gatewayaddr->setText("0.0.0.0"); 806 gatewayaddr->setText("0.0.0.0");
807 gatewayaddr->setEnabled(false); 807 gatewayaddr->setEnabled(false);
808 gate_label->setEnabled(false); 808 gate_label->setEnabled(false);
809 } 809 }
810 else 810 else
811 { 811 {
812 gatewayaddr->setEnabled(true); 812 gatewayaddr->setEnabled(true);
813 gatewayaddr->setText(""); 813 gatewayaddr->setText("");
814 gate_label->setEnabled(true); 814 gate_label->setEnabled(true);
815 } 815 }
816} 816}
817 817
818 818
819 819
820ScriptWidget::ScriptWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) 820ScriptWidget::ScriptWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name )
821 : QWidget(parent, name),_pppdata(pd) 821 : QWidget(parent, name),_pppdata(pd)
822{ 822{
823 823
824 QVBoxLayout *tl = new QVBoxLayout(this, 0 ); 824 QVBoxLayout *tl = new QVBoxLayout(this, 0 );
825 se = new ScriptEdit(this); 825 se = new ScriptEdit(this);
826 connect(se, SIGNAL(returnPressed()), SLOT(addButton())); 826 connect(se, SIGNAL(returnPressed()), SLOT(addButton()));
827 tl->addWidget(se); 827 tl->addWidget(se);
828 828
829 // insert equal-sized buttons 829 // insert equal-sized buttons
830 QHBoxLayout *hl = new QHBoxLayout( this ); 830 QHBoxLayout *hl = new QHBoxLayout( this );
831 tl->addLayout( hl ); 831 tl->addLayout( hl );
832 add = new QPushButton( tr("Add"), this ); 832 add = new QPushButton( tr("Add"), this );
833 hl->addWidget( add ); 833 hl->addWidget( add );
834 connect(add, SIGNAL(clicked()), SLOT(addButton())); 834 connect(add, SIGNAL(clicked()), SLOT(addButton()));
835 insert = new QPushButton( tr("Insert"), this ); 835 insert = new QPushButton( tr("Insert"), this );
836 hl->addWidget( insert ); 836 hl->addWidget( insert );
837 connect(insert, SIGNAL(clicked()), SLOT(insertButton())); 837 connect(insert, SIGNAL(clicked()), SLOT(insertButton()));
838 remove = new QPushButton( tr("Remove"), this ); 838 remove = new QPushButton( tr("Remove"), this );
839 hl->addWidget( remove ); 839 hl->addWidget( remove );
840 connect(remove, SIGNAL(clicked()), SLOT(removeButton())); 840 connect(remove, SIGNAL(clicked()), SLOT(removeButton()));
841 841
842 QHBoxLayout *l12 = new QHBoxLayout(0); 842 QHBoxLayout *l12 = new QHBoxLayout(0);
843 tl->addLayout(l12); 843 tl->addLayout(l12);
844 stl = new QListBox(this); 844 stl = new QListBox(this);
845 // stl->setVScrollBarMode( QScrollView::AlwaysOff ); 845 // stl->setVScrollBarMode( QScrollView::AlwaysOff );
846 connect(stl, SIGNAL(highlighted(int)), SLOT(stlhighlighted(int))); 846 connect(stl, SIGNAL(highlighted(int)), SLOT(stlhighlighted(int)));
847 // stl->setMinimumSize(QSize(70, 140)); 847 // stl->setMinimumSize(QSize(70, 140));
848 848
849 sl = new QListBox(this); 849 sl = new QListBox(this);
850 // sl->setVScrollBarMode( QScrollView::AlwaysOff ); 850 // sl->setVScrollBarMode( QScrollView::AlwaysOff );
851 connect(sl, SIGNAL(highlighted(int)), SLOT(slhighlighted(int))); 851 connect(sl, SIGNAL(highlighted(int)), SLOT(slhighlighted(int)));
852 // sl->setMinimumSize(QSize(150, 140)); 852 // sl->setMinimumSize(QSize(150, 140));
853 853
854 slb = new QScrollBar(this); 854 slb = new QScrollBar(this);
855 // slb->setFixedWidth(slb->sizeHint().width()); 855 // slb->setFixedWidth(slb->sizeHint().width());
856 connect(slb, SIGNAL(valueChanged(int)), SLOT(scrolling(int))); 856 connect(slb, SIGNAL(valueChanged(int)), SLOT(scrolling(int)));
857 857
858 l12->addWidget(stl, 1); 858 l12->addWidget(stl, 1);
859 l12->addWidget(sl, 3); 859 l12->addWidget(sl, 3);
860 l12->addWidget(slb, 0); 860 l12->addWidget(slb, 0);
861 861
862 //load data from gpppdata 862 //load data from gpppdata
863 if(!isnewaccount) 863 if(!isnewaccount)
864 { 864 {
865 QStringList &comlist = _pppdata->scriptType(); 865 QStringList &comlist = _pppdata->scriptType();
866 QStringList &arglist = _pppdata->script(); 866 QStringList &arglist = _pppdata->script();
867 QStringList::Iterator itcom = comlist.begin(); 867 QStringList::Iterator itcom = comlist.begin();
868 QStringList::Iterator itarg = arglist.begin(); 868 QStringList::Iterator itarg = arglist.begin();
869 869
870 for ( ; 870 for ( ;
871 itcom != comlist.end() && itarg != arglist.end(); 871 itcom != comlist.end() && itarg != arglist.end();
872 ++itcom, ++itarg ) 872 ++itcom, ++itarg )
873 { 873 {
874 stl->insertItem(*itcom); 874 stl->insertItem(*itcom);
875 sl->insertItem(*itarg); 875 sl->insertItem(*itarg);
876 } 876 }
877 } 877 }
878 878
879 insert->setEnabled(false); 879 insert->setEnabled(false);
880 remove->setEnabled(false); 880 remove->setEnabled(false);
881 adjustScrollBar(); 881 adjustScrollBar();
882 tl->activate(); 882 tl->activate();
883} 883}
884 884
885bool ScriptWidget::check() 885bool ScriptWidget::check()
886{ 886{
887 uint lstart = 0; 887 uint lstart = 0;
888 uint lend = 0; 888 uint lend = 0;
889 uint errcnt = 0; 889 uint errcnt = 0;
890 890
891 if(sl->count() > 0) 891 if(sl->count() > 0)
892 { 892 {
893 for( uint i=0; i <= sl->count()-1; i++) 893 for( uint i=0; i <= sl->count()-1; i++)
894 { 894 {
895 if(stl->text(i) == "LoopStart") 895 if(stl->text(i) == "LoopStart")
896 { 896 {
897 lstart++; 897 lstart++;
898 } 898 }
899 if (stl->text(i) == "LoopEnd") 899 if (stl->text(i) == "LoopEnd")
900 { 900 {
901 lend++; 901 lend++;
902 } 902 }
903 if ( lend > lstart ) errcnt++; 903 if ( lend > lstart ) errcnt++;
904 } 904 }
905 return ( (errcnt == 0 ) && (lstart == lend) ); 905 return ( (errcnt == 0 ) && (lstart == lend) );
906 } 906 }
907 return true; 907 return true;
908} 908}
909 909
910 910
911void ScriptWidget::save() 911void ScriptWidget::save()
912{ 912{
913 QStringList typelist, arglist; 913 QStringList typelist, arglist;
914 for(uint i=0; i < sl->count(); i++) 914 for(uint i=0; i < sl->count(); i++)
915 { 915 {
916 typelist.append(stl->text(i)); 916 typelist.append(stl->text(i));
917 arglist.append(sl->text(i)); 917 arglist.append(sl->text(i));
918 } 918 }
919 _pppdata->setScriptType(typelist); 919 _pppdata->setScriptType(typelist);
920 _pppdata->setScript(arglist); 920 _pppdata->setScript(arglist);
921} 921}
922 922
923 923
924 924
925void ScriptWidget::adjustScrollBar() 925void ScriptWidget::adjustScrollBar()
926{ 926{
927 if((int)sl->count() <= sl->numItemsVisible()) 927 if((int)sl->count() <= sl->numItemsVisible())
928 slb->setRange(0, 0); 928 slb->setRange(0, 0);
929 else 929 else
930 slb->setRange(0, (sl->count() - sl->numItemsVisible())+1); 930 slb->setRange(0, (sl->count() - sl->numItemsVisible())+1);
931} 931}
932 932
933 933
934void ScriptWidget::scrolling(int i) 934void ScriptWidget::scrolling(int i)
935{ 935{
936 sl->setTopItem(i); 936 sl->setTopItem(i);
937 stl->setTopItem(i); 937 stl->setTopItem(i);
938} 938}
939 939
940 940
941void ScriptWidget::slhighlighted(int i) 941void ScriptWidget::slhighlighted(int i)
942{ 942{
943 insert->setEnabled(true); 943 insert->setEnabled(true);
944 remove->setEnabled(true); 944 remove->setEnabled(true);
945 stl->setCurrentItem(i); 945 stl->setCurrentItem(i);
946} 946}
947 947
948 948
949void ScriptWidget::stlhighlighted(int i) 949void ScriptWidget::stlhighlighted(int i)
950{ 950{
951 insert->setEnabled(true); 951 insert->setEnabled(true);
952 remove->setEnabled(true); 952 remove->setEnabled(true);
953 sl->setCurrentItem(i); 953 sl->setCurrentItem(i);
954} 954}
955 955
956 956
957void ScriptWidget::addButton() 957void ScriptWidget::addButton()
958{ 958{
959 //don't allow more than the maximum script entries 959 //don't allow more than the maximum script entries
960 if(sl->count() == MAX_SCRIPT_ENTRIES-1) 960 if(sl->count() == MAX_SCRIPT_ENTRIES-1)
961 return; 961 return;
962 962
963 switch(se->type()) 963 switch(se->type())
964 { 964 {
965 case ScriptEdit::Expect: 965 case ScriptEdit::Expect:
966 stl->insertItem("Expect"); 966 stl->insertItem("Expect");
967 sl->insertItem(se->text()); 967 sl->insertItem(se->text());
968 break; 968 break;
969 969
970 case ScriptEdit::Send: 970 case ScriptEdit::Send:
971 stl->insertItem("Send"); 971 stl->insertItem("Send");
972 sl->insertItem(se->text()); 972 sl->insertItem(se->text());
973 break; 973 break;
974 974
975 case ScriptEdit::SendNoEcho: 975 case ScriptEdit::SendNoEcho:
976 stl->insertItem("SendNoEcho"); 976 stl->insertItem("SendNoEcho");
977 sl->insertItem(se->text()); 977 sl->insertItem(se->text());
978 break; 978 break;
979 979
980 case ScriptEdit::Pause: 980 case ScriptEdit::Pause:
981 stl->insertItem("Pause"); 981 stl->insertItem("Pause");
982 sl->insertItem(se->text()); 982 sl->insertItem(se->text());
983 break; 983 break;
984 984
985 case ScriptEdit::Hangup: 985 case ScriptEdit::Hangup:
986 stl->insertItem("Hangup"); 986 stl->insertItem("Hangup");
987 sl->insertItem(""); 987 sl->insertItem("");
988 break; 988 break;
989 989
990 case ScriptEdit::Answer: 990 case ScriptEdit::Answer:
991 stl->insertItem("Answer"); 991 stl->insertItem("Answer");
992 sl->insertItem(""); 992 sl->insertItem("");
993 break; 993 break;
994 994
995 case ScriptEdit::Timeout: 995 case ScriptEdit::Timeout:
996 stl->insertItem("Timeout"); 996 stl->insertItem("Timeout");
997 sl->insertItem(se->text()); 997 sl->insertItem(se->text());
998 break; 998 break;
999 999
1000 case ScriptEdit::Password: 1000 case ScriptEdit::Password:
1001 stl->insertItem("Password"); 1001 stl->insertItem("Password");
1002 sl->insertItem(se->text()); 1002 sl->insertItem(se->text());
1003 break; 1003 break;
1004 1004
1005 case ScriptEdit::ID: 1005 case ScriptEdit::ID:
1006 stl->insertItem("ID"); 1006 stl->insertItem("ID");
1007 sl->insertItem(se->text()); 1007 sl->insertItem(se->text());
1008 break; 1008 break;
1009 1009
1010 case ScriptEdit::Prompt: 1010 case ScriptEdit::Prompt:
1011 stl->insertItem("Prompt"); 1011 stl->insertItem("Prompt");
1012 sl->insertItem(se->text()); 1012 sl->insertItem(se->text());
1013 break; 1013 break;
1014 1014
1015 case ScriptEdit::PWPrompt: 1015 case ScriptEdit::PWPrompt:
1016 stl->insertItem("PWPrompt"); 1016 stl->insertItem("PWPrompt");
1017 sl->insertItem(se->text()); 1017 sl->insertItem(se->text());
1018 break; 1018 break;
1019 1019
1020 case ScriptEdit::LoopStart: 1020 case ScriptEdit::LoopStart:
1021 stl->insertItem("LoopStart"); 1021 stl->insertItem("LoopStart");
1022 sl->insertItem(se->text()); 1022 sl->insertItem(se->text());
1023 break; 1023 break;
1024 1024
1025 case ScriptEdit::LoopEnd: 1025 case ScriptEdit::LoopEnd:
1026 stl->insertItem("LoopEnd"); 1026 stl->insertItem("LoopEnd");
1027 sl->insertItem(se->text()); 1027 sl->insertItem(se->text());
1028 break; 1028 break;
1029 1029
1030 case ScriptEdit::Scan: 1030 case ScriptEdit::Scan:
1031 stl->insertItem("Scan"); 1031 stl->insertItem("Scan");
1032 sl->insertItem(se->text()); 1032 sl->insertItem(se->text());
1033 break; 1033 break;
1034 1034
1035 case ScriptEdit::Save: 1035 case ScriptEdit::Save:
1036 stl->insertItem("Save"); 1036 stl->insertItem("Save");
1037 sl->insertItem(se->text()); 1037 sl->insertItem(se->text());
1038 break; 1038 break;
1039 1039
1040 default: 1040 default:
1041 break; 1041 break;
1042 } 1042 }
1043 1043
1044 //get the scrollbar adjusted, and scroll the list so we can see what 1044 //get the scrollbar adjusted, and scroll the list so we can see what
1045 //we're adding to 1045 //we're adding to
1046 adjustScrollBar(); 1046 adjustScrollBar();
1047 slb->setValue(slb->maxValue()); 1047 slb->setValue(slb->maxValue());
1048 1048
1049 //clear the text in the entry box 1049 //clear the text in the entry box
1050 se->setText(""); 1050 se->setText("");
1051} 1051}
1052 1052
1053 1053
1054void ScriptWidget::insertButton() 1054void ScriptWidget::insertButton()
1055{ 1055{
1056 //exit if there is no highlighted item, or we've reached the 1056 //exit if there is no highlighted item, or we've reached the
1057 //maximum entries in the script list 1057 //maximum entries in the script list
1058 if(sl->currentItem() < 0 || (sl->count() == MAX_SCRIPT_ENTRIES-1)) 1058 if(sl->currentItem() < 0 || (sl->count() == MAX_SCRIPT_ENTRIES-1))
1059 return; 1059 return;
1060 1060
1061 switch(se->type()) 1061 switch(se->type())
1062 { 1062 {
1063 case ScriptEdit::Expect: 1063 case ScriptEdit::Expect:
1064 stl->insertItem("Expect", stl->currentItem()); 1064 stl->insertItem("Expect", stl->currentItem());
1065 sl->insertItem(se->text(), sl->currentItem()); 1065 sl->insertItem(se->text(), sl->currentItem());
1066 break; 1066 break;
1067 1067
1068 case ScriptEdit::Send: 1068 case ScriptEdit::Send:
1069 stl->insertItem("Send", stl->currentItem()); 1069 stl->insertItem("Send", stl->currentItem());
1070 sl->insertItem(se->text(), sl->currentItem()); 1070 sl->insertItem(se->text(), sl->currentItem());
1071 break; 1071 break;
1072 1072
1073 case ScriptEdit::SendNoEcho: 1073 case ScriptEdit::SendNoEcho:
1074 stl->insertItem("SendNoEcho", stl->currentItem()); 1074 stl->insertItem("SendNoEcho", stl->currentItem());
1075 sl->insertItem(se->text(), sl->currentItem()); 1075 sl->insertItem(se->text(), sl->currentItem());
1076 break; 1076 break;
1077 1077
1078 case ScriptEdit::Pause: 1078 case ScriptEdit::Pause:
1079 stl->insertItem("Pause", stl->currentItem()); 1079 stl->insertItem("Pause", stl->currentItem());
1080 sl->insertItem(se->text(), sl->currentItem()); 1080 sl->insertItem(se->text(), sl->currentItem());
1081 break; 1081 break;
1082 1082
1083 case ScriptEdit::Hangup: 1083 case ScriptEdit::Hangup:
1084 stl->insertItem("Hangup", stl->currentItem()); 1084 stl->insertItem("Hangup", stl->currentItem());
1085 sl->insertItem("", sl->currentItem()); 1085 sl->insertItem("", sl->currentItem());
1086 break; 1086 break;
1087 1087
1088 case ScriptEdit::Answer: 1088 case ScriptEdit::Answer:
1089 stl->insertItem("Answer", stl->currentItem()); 1089 stl->insertItem("Answer", stl->currentItem());
1090 sl->insertItem("", sl->currentItem()); 1090 sl->insertItem("", sl->currentItem());
1091 break; 1091 break;
1092 1092
1093 case ScriptEdit::Timeout: 1093 case ScriptEdit::Timeout:
1094 stl->insertItem("Timeout", stl->currentItem()); 1094 stl->insertItem("Timeout", stl->currentItem());
1095 sl->insertItem(se->text(), sl->currentItem()); 1095 sl->insertItem(se->text(), sl->currentItem());
1096 break; 1096 break;
1097 1097
1098 case ScriptEdit::Password: 1098 case ScriptEdit::Password:
1099 stl->insertItem("Password", stl->currentItem()); 1099 stl->insertItem("Password", stl->currentItem());
1100 sl->insertItem(se->text(), sl->currentItem()); 1100 sl->insertItem(se->text(), sl->currentItem());
1101 break; 1101 break;
1102 1102
1103 case ScriptEdit::ID: 1103 case ScriptEdit::ID:
1104 stl->insertItem("ID", stl->currentItem()); 1104 stl->insertItem("ID", stl->currentItem());
1105 sl->insertItem(se->text(), sl->currentItem()); 1105 sl->insertItem(se->text(), sl->currentItem());
1106 break; 1106 break;
1107 1107
1108 case ScriptEdit::Prompt: 1108 case ScriptEdit::Prompt:
1109 stl->insertItem("Prompt", stl->currentItem()); 1109 stl->insertItem("Prompt", stl->currentItem());
1110 sl->insertItem(se->text(), sl->currentItem()); 1110 sl->insertItem(se->text(), sl->currentItem());
1111 break; 1111 break;
1112 1112
1113 case ScriptEdit::PWPrompt: 1113 case ScriptEdit::PWPrompt:
1114 stl->insertItem("PWPrompt", stl->currentItem()); 1114 stl->insertItem("PWPrompt", stl->currentItem());
1115 sl->insertItem(se->text(), sl->currentItem()); 1115 sl->insertItem(se->text(), sl->currentItem());
1116 break; 1116 break;
1117 1117
1118 case ScriptEdit::LoopStart: 1118 case ScriptEdit::LoopStart:
1119 stl->insertItem("LoopStart", stl->currentItem()); 1119 stl->insertItem("LoopStart", stl->currentItem());
1120 sl->insertItem(se->text(), sl->currentItem()); 1120 sl->insertItem(se->text(), sl->currentItem());
1121 break; 1121 break;
1122 1122
1123 case ScriptEdit::LoopEnd: 1123 case ScriptEdit::LoopEnd:
1124 stl->insertItem("LoopEnd", stl->currentItem()); 1124 stl->insertItem("LoopEnd", stl->currentItem());
1125 sl->insertItem(se->text(), sl->currentItem()); 1125 sl->insertItem(se->text(), sl->currentItem());
1126 break; 1126 break;
1127 1127
1128 case ScriptEdit::Scan: 1128 case ScriptEdit::Scan:
1129 stl->insertItem("Scan", stl->currentItem()); 1129 stl->insertItem("Scan", stl->currentItem());
1130 sl->insertItem(se->text(), sl->currentItem()); 1130 sl->insertItem(se->text(), sl->currentItem());
1131 break; 1131 break;
1132 1132
1133 case ScriptEdit::Save: 1133 case ScriptEdit::Save:
1134 stl->insertItem("Save", stl->currentItem()); 1134 stl->insertItem("Save", stl->currentItem());
1135 sl->insertItem(se->text(), sl->currentItem()); 1135 sl->insertItem(se->text(), sl->currentItem());
1136 break; 1136 break;
1137 1137
1138 default: 1138 default:
1139 break; 1139 break;
1140 } 1140 }
1141 adjustScrollBar(); 1141 adjustScrollBar();
1142 se->setText(""); 1142 se->setText("");
1143} 1143}
1144 1144
1145 1145
1146void ScriptWidget::removeButton() 1146void ScriptWidget::removeButton()
1147{ 1147{
1148 if(sl->currentItem() >= 0) 1148 if(sl->currentItem() >= 0)
1149 { 1149 {
1150 int stlc = stl->currentItem(); 1150 int stlc = stl->currentItem();
1151 sl->removeItem(sl->currentItem()); 1151 sl->removeItem(sl->currentItem());
1152 stl->removeItem(stlc); 1152 stl->removeItem(stlc);
1153 adjustScrollBar(); 1153 adjustScrollBar();
1154 insert->setEnabled(sl->currentItem() != -1); 1154 insert->setEnabled(sl->currentItem() != -1);
1155 remove->setEnabled(sl->currentItem() != -1); 1155 remove->setEnabled(sl->currentItem() != -1);
1156 } 1156 }
1157} 1157}
1158 1158
1159 1159
1160 1160
1161///////////////////////////////////////////////////////////////////////////// 1161/////////////////////////////////////////////////////////////////////////////
1162// 1162//
1163// Used to specify a new phone number 1163// Used to specify a new phone number
1164// 1164//
1165///////////////////////////////////////////////////////////////////////////// 1165/////////////////////////////////////////////////////////////////////////////
1166PhoneNumberDialog::PhoneNumberDialog(QWidget *parent) 1166PhoneNumberDialog::PhoneNumberDialog(QWidget *parent)
1167 : QDialog(parent,"PhoneNumberDialog",true) 1167 : QDialog(parent,"PhoneNumberDialog",true)
1168{ 1168{
1169 setCaption( tr("Add Phone Number") ); 1169 setCaption( tr("Add Phone Number") );
1170 1170
1171 1171
1172 QVBoxLayout *layout = new QVBoxLayout( this ); 1172 QVBoxLayout *layout = new QVBoxLayout( this );
1173 layout->setSpacing( 3 ); 1173 layout->setSpacing( 3 );
1174 layout->setMargin( 3 ); 1174 layout->setMargin( 3 );
1175 1175
1176 // QHBox *hbox = new QHBox(this); 1176 // QHBox *hbox = new QHBox(this);
1177 // setMainWidget(hbox); 1177 // setMainWidget(hbox);
1178 1178
1179 // hbox->setSpacing( 2 );//KDialog::spacingHint()); 1179 // hbox->setSpacing( 2 );//KDialog::spacingHint());
1180 1180
1181 QLabel *label = new QLabel(this, tr("Enter a phone number:")); 1181 QLabel *label = new QLabel(this, tr("Enter a phone number:"));
1182 layout->addWidget( label ); 1182 layout->addWidget( label );
1183 1183
1184 le = new QLineEdit(this, "lineEdit"); 1184 le = new QLineEdit(this, "lineEdit");
1185 layout->addWidget( le ); 1185 layout->addWidget( le );
1186 1186
1187 connect(le, SIGNAL(textChanged(const QString&)), 1187 connect(le, SIGNAL(textChanged(const QString&)),
1188 this, SLOT(textChanged(const QString&))); 1188 this, SLOT(textChanged(const QString&)));
1189 1189
1190 le->setFocus(); 1190 le->setFocus();
1191 textChanged(""); 1191 textChanged("");
1192 1192
1193 1193
1194} 1194}
1195 1195
1196 1196
1197QString PhoneNumberDialog::phoneNumber() 1197QString PhoneNumberDialog::phoneNumber()
1198{ 1198{
1199 QString s = le->text(); 1199 QString s = le->text();
1200 1200
1201 return s; 1201 return s;
1202} 1202}
1203 1203
1204 1204
1205void PhoneNumberDialog::textChanged(const QString &s) 1205void PhoneNumberDialog::textChanged(const QString &)
1206{ 1206{
1207 // enableButtonOK(s.length() > 0); 1207 // enableButtonOK(s.length() > 0);
1208} 1208}
1209 1209
1210 1210
1211//#include "edit.moc" 1211//#include "edit.moc"
diff --git a/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp b/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp
index 4755aed..56e1c1f 100644
--- a/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp
+++ b/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp
@@ -1,45 +1,45 @@
1#include "interfaceinformationppp.h" 1#include "interfaceinformationppp.h"
2#include "connect.h" 2#include "connect.h"
3#include "conwindow.h" 3#include "conwindow.h"
4 4
5/* OPIE */ 5/* OPIE */
6#include <opie2/odebug.h> 6#include <opie2/odebug.h>
7using namespace Opie::Core; 7using namespace Opie::Core;
8 8
9/* QT */ 9/* QT */
10#include <qpushbutton.h> 10#include <qpushbutton.h>
11#include <qlabel.h> 11#include <qlabel.h>
12#include <qmessagebox.h> 12#include <qmessagebox.h>
13#include <qabstractlayout.h> 13#include <qabstractlayout.h>
14 14
15#ifdef QWS 15#ifdef QWS
16#else 16#else
17 #define showMaximized show 17 #define showMaximized show
18#endif 18#endif
19 19
20/** 20/**
21 * Constructor for the InterfaceInformationImp class. This class pretty much 21 * Constructor for the InterfaceInformationImp class. This class pretty much
22 * 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.
23 */ 23 */
24InterfaceInformationPPP::InterfaceInformationPPP(QWidget *parent, const char *name, Interface *i, WFlags f) 24InterfaceInformationPPP::InterfaceInformationPPP(QWidget *parent, const char *name, Interface *i, WFlags )
25 :InterfaceInformationImp(parent, name, i, Qt::WStyle_ContextHelp) 25 :InterfaceInformationImp(parent, name, i, Qt::WStyle_ContextHelp)
26{ 26{
27 odebug << "InterfaceInformationPPP::InterfaceInformationPPP " << name << "" << oendl; 27 odebug << "InterfaceInformationPPP::InterfaceInformationPPP " << name << "" << oendl;
28 con = new ConnectWidget( (InterfacePPP*)i, this, "con" ); 28 con = new ConnectWidget( (InterfacePPP*)i, this, "con" );
29 con->setSizePolicy( QSizePolicy(QSizePolicy::MinimumExpanding, 29 con->setSizePolicy( QSizePolicy(QSizePolicy::MinimumExpanding,
30 QSizePolicy::Fixed) ); 30 QSizePolicy::Fixed) );
31 31
32 macAddressLabel->hide(); 32 macAddressLabel->hide();
33 subnetMaskLabel->hide(); 33 subnetMaskLabel->hide();
34 broadcastLabel->hide(); 34 broadcastLabel->hide();
35 TextLabel23->hide(); 35 TextLabel23->hide();
36 TextLabel21->hide(); 36 TextLabel21->hide();
37 TextLabel24->hide(); 37 TextLabel24->hide();
38 38
39 InterfaceInformationLayout->addWidget( con, 1, 0 ); 39 InterfaceInformationLayout->addWidget( con, 1, 0 );
40 connect(i, SIGNAL(begin_connect()),con, SLOT(preinit())); 40 connect(i, SIGNAL(begin_connect()),con, SLOT(preinit()));
41 connect(i, SIGNAL(hangup_now() ), con, SLOT(cancelbutton() ) ); 41 connect(i, SIGNAL(hangup_now() ), con, SLOT(cancelbutton() ) );
42} 42}
43 43
44 44
45 45
diff --git a/noncore/settings/networksettings/ppp/pppmodule.cpp b/noncore/settings/networksettings/ppp/pppmodule.cpp
index fb279ee..dec0177 100644
--- a/noncore/settings/networksettings/ppp/pppmodule.cpp
+++ b/noncore/settings/networksettings/ppp/pppmodule.cpp
@@ -1,286 +1,287 @@
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 <opie2/odebug.h>
11#include <qpe/config.h> 11#include <qpe/config.h>
12#include <qpe/qpeapplication.h> 12#include <qpe/qpeapplication.h>
13using namespace Opie::Core; 13using namespace Opie::Core;
14 14
15/* QT */ 15/* QT */
16#include <qt.h> 16#include <qt.h>
17 17
18/* STD */ 18/* STD */
19#include <errno.h> 19#include <errno.h>
20#include <signal.h> 20#include <signal.h>
21 21
22// don't polute global namespace 22// don't polute global namespace
23namespace 23namespace
24{ 24{
25 /* 25 /*
26 * If network settings is qutting and we've ppp 26 * If network settings is qutting and we've ppp
27 * devices open we need to save the pid_t the PPData 27 * devices open we need to save the pid_t the PPData
28 * and the interface number 28 * and the interface number
29 */ 29 */
30 struct Connection 30 struct Connection
31 { 31 {
32 pid_t pid; 32 pid_t pid;
33 QString device; 33 QString device;
34 QString name; 34 QString name;
35 }; 35 };
36 class InterfaceKeeper 36 class InterfaceKeeper
37 { 37 {
38 public: 38 public:
39 InterfaceKeeper(); 39 InterfaceKeeper();
40 ~InterfaceKeeper(); 40 ~InterfaceKeeper();
41 41
42 void addInterface( pid_t, const QString& pppDev, const QString& name ); 42 void addInterface( pid_t, const QString& pppDev, const QString& name );
43 QMap<QString, Connection> interfaces()const; // will check if still available 43 QMap<QString, Connection> interfaces()const; // will check if still available
44 private: 44 private:
45 bool isAvailable( pid_t )const; 45 bool isAvailable( pid_t )const;
46 QMap<QString, Connection> m_interfaces; 46 QMap<QString, Connection> m_interfaces;
47 }; 47 };
48} 48}
49 49
50 50
51/** 51/**
52 * Constructor, find all of the possible interfaces 52 * Constructor, find all of the possible interfaces
53 * We also need to restore the state.. it could be that 53 * We also need to restore the state.. it could be that
54 * an interface was up while closing the application 54 * an interface was up while closing the application
55 * we need to be able to shut it down... 55 * we need to be able to shut it down...
56 */ 56 */
57PPPModule::PPPModule() : Module() 57PPPModule::PPPModule() : Module()
58{ 58{
59 InterfaceKeeper inFace; 59 InterfaceKeeper inFace;
60 QMap<QString,Connection> running = inFace.interfaces(); 60 QMap<QString,Connection> running = inFace.interfaces();
61 QStringList handledInterfaceNames; 61 QStringList handledInterfaceNames;
62 62
63 QMap<QString,QString> ifaces = PPPData::getConfiguredInterfaces(); 63 QMap<QString,QString> ifaces = PPPData::getConfiguredInterfaces();
64 QMap<QString,QString>::Iterator it; 64 QMap<QString,QString>::Iterator it;
65 InterfacePPP *iface; 65 InterfacePPP *iface;
66 odebug << "getting interfaces" << oendl; 66 odebug << "getting interfaces" << oendl;
67 for( it = ifaces.begin(); it != ifaces.end(); ++it ) 67 for( it = ifaces.begin(); it != ifaces.end(); ++it )
68 { 68 {
69 odebug << "ifaces " << it.key().latin1() << " " << it.data().latin1() << "" << oendl; 69 odebug << "ifaces " << it.key().latin1() << " " << it.data().latin1() << "" << oendl;
70 iface = new InterfacePPP( 0, it.key() ); 70 iface = new InterfacePPP( 0, it.key() );
71 iface->setHardwareName( it.data() ); 71 iface->setHardwareName( it.data() );
72 list.append( (Interface*)iface ); 72 list.append( (Interface*)iface );
73 73
74 // check if (*it) is one of the running ifaces 74 // check if (*it) is one of the running ifaces
75 if ( running.contains( it.data() ) ) 75 if ( running.contains( it.data() ) )
76 { 76 {
77 odebug << "iface is running " << it.key().latin1() << "" << oendl; 77 odebug << "iface is running " << it.key().latin1() << "" << oendl;
78 handledInterfaceNames << running[it.data()].device; 78 handledInterfaceNames << running[it.data()].device;
79 iface->setStatus( true ); 79 iface->setStatus( true );
80 iface->setPPPDpid( running[it.data()].pid ); 80 iface->setPPPDpid( running[it.data()].pid );
81 iface->modem()->setPPPDevice( running[it.data()].device ); 81 iface->modem()->setPPPDevice( running[it.data()].device );
82 iface->refresh(); 82 iface->refresh();
83 } 83 }
84 } 84 }
85 85
86 setHandledInterfaceNames( handledInterfaceNames ); 86 setHandledInterfaceNames( handledInterfaceNames );
87} 87}
88 88
89/** 89/**
90 * Delete any interfaces that we own. 90 * Delete any interfaces that we own.
91 */ 91 */
92PPPModule::~PPPModule() 92PPPModule::~PPPModule()
93{ 93{
94 odebug << "PPPModule::~PPPModule() " << oendl; 94 odebug << "PPPModule::~PPPModule() " << oendl;
95 QMap<QString,QString> ifaces; 95 QMap<QString,QString> ifaces;
96 InterfaceKeeper keeper; 96 InterfaceKeeper keeper;
97 Interface *i; 97 Interface *i;
98 for ( i=list.first(); i != 0; i=list.next() ) 98 for ( i=list.first(); i != 0; i=list.next() )
99 { 99 {
100 /* if online save the state */ 100 /* if online save the state */
101 if ( i->getStatus() ) 101 if ( i->getStatus() )
102 { 102 {
103 odebug << "Iface " << i->getHardwareName().latin1() << " is still up" << oendl; 103 odebug << "Iface " << i->getHardwareName().latin1() << " is still up" << oendl;
104 InterfacePPP* ppp = static_cast<InterfacePPP*>(i); 104 InterfacePPP* ppp = static_cast<InterfacePPP*>(i);
105 keeper.addInterface( ppp->pppPID(), ppp->pppDev(), ppp->getHardwareName() ); 105 keeper.addInterface( ppp->pppPID(), ppp->pppDev(), ppp->getHardwareName() );
106 } 106 }
107 ifaces.insert( i->getInterfaceName(), i->getHardwareName() ); 107 ifaces.insert( i->getInterfaceName(), i->getHardwareName() );
108 delete i; 108 delete i;
109 } 109 }
110 PPPData::setConfiguredInterfaces( ifaces ); 110 PPPData::setConfiguredInterfaces( ifaces );
111} 111}
112 112
113/** 113/**
114 * Change the current profile 114 * Change the current profile
115 */ 115 */
116void PPPModule::setProfile(const QString &newProfile) 116void PPPModule::setProfile(const QString &newProfile)
117{ 117{
118 profile = newProfile; 118 profile = newProfile;
119} 119}
120 120
121/** 121/**
122 * get the icon name for this device. 122 * get the icon name for this device.
123 * @param Interface* can be used in determining the icon. 123 * @param Interface* can be used in determining the icon.
124 * @return QString the icon name (minus .png, .gif etc) 124 * @return QString the icon name (minus .png, .gif etc)
125 */ 125 */
126QString PPPModule::getPixmapName(Interface* ) 126QString PPPModule::getPixmapName(Interface* )
127{ 127{
128 return "ppp"; 128 return "ppp";
129} 129}
130 130
131/** 131/**
132 * Check to see if the interface i is owned by this module. 132 * Check to see if the interface i is owned by this module.
133 * @param Interface* interface to check against 133 * @param Interface* interface to check against
134 * @return bool true if i is owned by this module, false otherwise. 134 * @return bool true if i is owned by this module, false otherwise.
135 */ 135 */
136bool PPPModule::isOwner(Interface *i) 136bool PPPModule::isOwner(Interface *i)
137{ 137{
138 return list.find( i ) != -1; 138 return list.find( i ) != -1;
139} 139}
140 140
141/** 141/**
142 * Create, and return the WLANConfigure Module 142 * Create, and return the WLANConfigure Module
143 * @return QWidget* pointer to this modules configure. 143 * @return QWidget* pointer to this modules configure.
144 */ 144 */
145QWidget *PPPModule::configure(Interface *i) 145QWidget *PPPModule::configure(Interface *i)
146{ 146{
147 odebug << "return ModemWidget" << oendl; 147 odebug << "return ModemWidget" << oendl;
148 PPPConfigWidget *pppconfig = new PPPConfigWidget( (InterfacePPP*)i, 148 PPPConfigWidget *pppconfig = new PPPConfigWidget( (InterfacePPP*)i,
149 0, "PPPConfig", false, 149 0, "PPPConfig", false,
150 ::Qt::WDestructiveClose | ::Qt::WStyle_ContextHelp); 150 ::Qt::WDestructiveClose | ::Qt::WStyle_ContextHelp);
151 return pppconfig; 151 return pppconfig;
152} 152}
153 153
154/** 154/**
155 * Create, and return the Information Module 155 * Create, and return the Information Module
156 * @return QWidget* pointer to this modules info. 156 * @return QWidget* pointer to this modules info.
157 */ 157 */
158QWidget *PPPModule::information(Interface *i) 158QWidget *PPPModule::information(Interface *i)
159{ 159{
160 // We don't have any advanced pppd information widget yet :-D 160 // We don't have any advanced pppd information widget yet :-D
161 // TODO ^ 161 // TODO ^
162 162
163 return new InterfaceInformationPPP( 0, "InterfaceInformationPPP", i ); 163 return new InterfaceInformationPPP( 0, "InterfaceInformationPPP", i );
164} 164}
165 165
166/** 166/**
167 * Get all active (up or down) interfaces 167 * Get all active (up or down) interfaces
168 * @return QList<Interface> A list of interfaces that exsist that havn't 168 * @return QList<Interface> A list of interfaces that exsist that havn't
169 * been called by isOwner() 169 * been called by isOwner()
170 */ 170 */
171QList<Interface> PPPModule::getInterfaces() 171QList<Interface> PPPModule::getInterfaces()
172{ 172{
173 // List all of the files in the peer directory 173 // List all of the files in the peer directory
174 odebug << "PPPModule::getInterfaces" << oendl; 174 odebug << "PPPModule::getInterfaces" << oendl;
175 return list; 175 return list;
176} 176}
177 177
178/** 178/**
179 * Attempt to add a new interface as defined by name 179 * Attempt to add a new interface as defined by name
180 * @param name the name of the type of interface that should be created given 180 * @param newInterface the name of the type of interface that should be created given
181 * by possibleNewInterfaces(); 181 * by possibleNewInterfaces();
182 * @return Interface* NULL if it was unable to be created. 182 * @return Interface* NULL if it was unable to be created.
183 */ 183 */
184Interface *PPPModule::addNewInterface(const QString &newInterface) 184Interface *PPPModule::addNewInterface(const QString &newInterface)
185{ 185{
186 Q_CONST_UNUSED( newInterface )
186 187
187 InterfacePPP *ifaceppp; 188 InterfacePPP *ifaceppp;
188 Interface *iface; 189 Interface *iface;
189 ifaceppp = new InterfacePPP(); 190 ifaceppp = new InterfacePPP();
190 PPPConfigWidget imp(ifaceppp, 0, "PPPConfigImp", true); 191 PPPConfigWidget imp(ifaceppp, 0, "PPPConfigImp", true);
191 192
192 if( QPEApplication::execDialog( &imp ) == QDialog::Accepted ) 193 if( QPEApplication::execDialog( &imp ) == QDialog::Accepted )
193 { 194 {
194 iface = (InterfacePPP*) ifaceppp; 195 iface = (InterfacePPP*) ifaceppp;
195 iface->setModuleOwner( this ); 196 iface->setModuleOwner( this );
196 list.append( iface ); 197 list.append( iface );
197 return iface; 198 return iface;
198 } 199 }
199 else 200 else
200 { 201 {
201 delete ifaceppp; 202 delete ifaceppp;
202 iface = NULL; 203 iface = NULL;
203 } 204 }
204 return iface; 205 return iface;
205} 206}
206 207
207/** 208/**
208 * Attempts to remove the interface, doesn't delete i 209 * Attempts to remove the interface, doesn't delete i
209 * @return bool true if successful, false otherwise. 210 * @return bool true if successful, false otherwise.
210 */ 211 */
211bool PPPModule::remove(Interface *i) 212bool PPPModule::remove(Interface *i)
212{ 213{
213 return list.remove(i); 214 return list.remove(i);
214} 215}
215 216
216void PPPModule::possibleNewInterfaces(QMap<QString, QString> &newIfaces) 217void PPPModule::possibleNewInterfaces(QMap<QString, QString> &newIfaces)
217{ 218{
218 newIfaces.insert(::QObject::tr("PPP") , 219 newIfaces.insert(::QObject::tr("PPP") ,
219 ::QObject::tr("generic ppp device")); 220 ::QObject::tr("generic ppp device"));
220} 221}
221 222
222 223
223 224
224namespace 225namespace
225{ 226{
226 InterfaceKeeper::InterfaceKeeper( ) 227 InterfaceKeeper::InterfaceKeeper( )
227 {} 228 {}
228 InterfaceKeeper::~InterfaceKeeper() 229 InterfaceKeeper::~InterfaceKeeper()
229 { 230 {
230 Config cfg("ppp_plugin_keeper"); 231 Config cfg("ppp_plugin_keeper");
231 QStringList lst = cfg.groupList(); 232 QStringList lst = cfg.groupList();
232 for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) 233 for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it )
233 { 234 {
234 Connection con; 235 Connection con;
235 cfg.setGroup( (*it) ); 236 cfg.setGroup( (*it) );
236 cfg.clearGroup(); 237 cfg.clearGroup();
237 } 238 }
238 239
239 for (QMap<QString, Connection>::Iterator it = m_interfaces.begin(); it != m_interfaces.end(); ++it ) 240 for (QMap<QString, Connection>::Iterator it = m_interfaces.begin(); it != m_interfaces.end(); ++it )
240 { 241 {
241 Connection con = it.data(); 242 Connection con = it.data();
242 cfg.setGroup( con.name ); 243 cfg.setGroup( con.name );
243 cfg.writeEntry( "pid", con.pid ); 244 cfg.writeEntry( "pid", con.pid );
244 cfg.writeEntry( "device", con.device ); 245 cfg.writeEntry( "device", con.device );
245 } 246 }
246 } 247 }
247 void InterfaceKeeper::addInterface(pid_t pid, const QString& dev, const QString& name ) 248 void InterfaceKeeper::addInterface(pid_t pid, const QString& dev, const QString& name )
248 { 249 {
249 Connection con; 250 Connection con;
250 con.pid = pid; 251 con.pid = pid;
251 con.device = dev; 252 con.device = dev;
252 con.name = name; 253 con.name = name;
253 m_interfaces.insert( name, con ); 254 m_interfaces.insert( name, con );
254 } 255 }
255 QMap<QString, Connection> InterfaceKeeper::interfaces()const 256 QMap<QString, Connection> InterfaceKeeper::interfaces()const
256 { 257 {
257 Config cfg("ppp_plugin_keeper"); 258 Config cfg("ppp_plugin_keeper");
258 QMap<QString, Connection> ifaces; 259 QMap<QString, Connection> ifaces;
259 QStringList lst = cfg.groupList(); 260 QStringList lst = cfg.groupList();
260 for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) 261 for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it )
261 { 262 {
262 Connection con; 263 Connection con;
263 cfg.setGroup( (*it) ); 264 cfg.setGroup( (*it) );
264 con.name = (*it); 265 con.name = (*it);
265 con.pid = cfg.readNumEntry("pid"); 266 con.pid = cfg.readNumEntry("pid");
266 con.device = cfg.readEntry("device"); 267 con.device = cfg.readEntry("device");
267 odebug << " " << con.name.latin1() << " " << con.device.latin1() << " " << con.pid << "" << oendl; 268 odebug << " " << con.name.latin1() << " " << con.device.latin1() << " " << con.pid << "" << oendl;
268 269
269 if ( con.pid != -1 && isAvailable( con.pid ) ) 270 if ( con.pid != -1 && isAvailable( con.pid ) )
270 ifaces.insert( con.name, con ); 271 ifaces.insert( con.name, con );
271 } 272 }
272 return ifaces; 273 return ifaces;
273 } 274 }
274 bool InterfaceKeeper::isAvailable( pid_t p)const 275 bool InterfaceKeeper::isAvailable( pid_t p)const
275 { 276 {
276 if (::kill(p, 0 ) == 0 || errno != ESRCH ) 277 if (::kill(p, 0 ) == 0 || errno != ESRCH )
277 { 278 {
278 odebug << "isAvailable " << p << "" << oendl; 279 odebug << "isAvailable " << p << "" << oendl;
279 return true; 280 return true;
280 } 281 }
281 282
282 odebug << "notAvailable " << p << "" << oendl; 283 odebug << "notAvailable " << p << "" << oendl;
283 return false; 284 return false;
284 } 285 }
285 286
286} 287}
diff --git a/noncore/settings/networksettings/ppp/pppmodule.h b/noncore/settings/networksettings/ppp/pppmodule.h
index de649e4..1ecbf7a 100644
--- a/noncore/settings/networksettings/ppp/pppmodule.h
+++ b/noncore/settings/networksettings/ppp/pppmodule.h
@@ -1,43 +1,43 @@
1#ifndef PPP_MODULE_H 1#ifndef PPP_MODULE_H
2#define PPP_MODULE_H 2#define PPP_MODULE_H
3 3
4#include "module.h" 4#include "module.h"
5 5
6class PPPModule : Module { 6class PPPModule : Module {
7 7
8signals: 8signals:
9 void updateInterface(Interface *i); 9 void updateInterface(Interface *i);
10 10
11public: 11public:
12 PPPModule(); 12 PPPModule();
13 ~PPPModule(); 13 ~PPPModule();
14 14
15 virtual const QString type() {return "ppp";}; 15 virtual const QString type() {return "ppp";};
16 virtual void setProfile(const QString &newProfile); 16 virtual void setProfile(const QString &newProfile);
17 virtual bool isOwner(Interface *); 17 virtual bool isOwner(Interface *);
18 virtual QWidget *configure(Interface *i); 18 virtual QWidget *configure(Interface *i);
19 virtual QWidget *information(Interface *i); 19 virtual QWidget *information(Interface *i);
20 virtual QList<Interface> getInterfaces(); 20 virtual QList<Interface> getInterfaces();
21 virtual void possibleNewInterfaces(QMap<QString, QString> &); 21 virtual void possibleNewInterfaces(QMap<QString, QString> &);
22 virtual Interface *addNewInterface(const QString &name); 22 virtual Interface *addNewInterface(const QString &name);
23 virtual bool remove(Interface* i); 23 virtual bool remove(Interface* i);
24 virtual QString getPixmapName(Interface* i); 24 virtual QString getPixmapName(Interface* i);
25 virtual void receive(const QCString &msg, const QByteArray &arg) {}; 25 virtual void receive(const QCString &, const QByteArray &) {};
26 26
27private: 27private:
28 QList<Interface> list; 28 QList<Interface> list;
29 QString profile; 29 QString profile;
30 30
31}; 31};
32 32
33extern "C" 33extern "C"
34{ 34{
35 void* create_plugin() { 35 void* create_plugin() {
36 return new PPPModule(); 36 return new PPPModule();
37 } 37 }
38}; 38};
39 39
40#endif 40#endif
41 41
42// pppmodule.h 42// pppmodule.h
43 43
diff --git a/noncore/settings/networksettings/wlan/keyedit.cpp b/noncore/settings/networksettings/wlan/keyedit.cpp
index 13a1c3b..62f8960 100644
--- a/noncore/settings/networksettings/wlan/keyedit.cpp
+++ b/noncore/settings/networksettings/wlan/keyedit.cpp
@@ -1,22 +1,22 @@
1#include "keyedit.h" 1#include "keyedit.h"
2#include <qlineedit.h> 2#include <qlineedit.h>
3 3
4KeyEdit::KeyEdit(QWidget* parent, const char* name) : 4KeyEdit::KeyEdit(QWidget* parent, const char* name) :
5 QLineEdit(parent, name) 5 QLineEdit(parent, name)
6{ 6{
7 setEchoMode(Password); 7 setEchoMode(Password);
8} 8}
9 9
10KeyEdit::~KeyEdit() 10KeyEdit::~KeyEdit()
11{ 11{
12} 12}
13 13
14void KeyEdit::focusInEvent(QFocusEvent *event) 14void KeyEdit::focusInEvent(QFocusEvent *)
15{ 15{
16 setEchoMode(Normal); 16 setEchoMode(Normal);
17} 17}
18 18
19void KeyEdit::focusOutEvent(QFocusEvent *event) 19void KeyEdit::focusOutEvent(QFocusEvent *)
20{ 20{
21 setEchoMode(Password); 21 setEchoMode(Password);
22} 22}
diff --git a/noncore/settings/networksettings/wlan/wlanimp2.cpp b/noncore/settings/networksettings/wlan/wlanimp2.cpp
index d36a702..5cb78cf 100644
--- a/noncore/settings/networksettings/wlan/wlanimp2.cpp
+++ b/noncore/settings/networksettings/wlan/wlanimp2.cpp
@@ -1,493 +1,492 @@
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#include "../interfaces/interface.h" 4#include "../interfaces/interface.h"
5 5
6#include <assert.h> 6#include <assert.h>
7#include <errno.h> 7#include <errno.h>
8#include <string.h> 8#include <string.h>
9 9
10/* OPIE */ 10/* OPIE */
11#include <opie2/odebug.h> 11#include <opie2/odebug.h>
12#include <opie2/oprocess.h> 12#include <opie2/oprocess.h>
13#include <opie2/onetwork.h> 13#include <opie2/onetwork.h>
14#include <opie2/opcap.h> 14#include <opie2/opcap.h>
15#include <qpe/resource.h> 15#include <qpe/resource.h>
16using namespace Opie::Core; 16using namespace Opie::Core;
17using namespace Opie::Net; 17using namespace Opie::Net;
18 18
19/* QT */ 19/* QT */
20#include <qapplication.h> 20#include <qapplication.h>
21#include <qfile.h> 21#include <qfile.h>
22#include <qdir.h> 22#include <qdir.h>
23#include <qdialog.h> 23#include <qdialog.h>
24#include <qtextstream.h> 24#include <qtextstream.h>
25#include <qmessagebox.h> 25#include <qmessagebox.h>
26#include <qlineedit.h> 26#include <qlineedit.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qspinbox.h> 28#include <qspinbox.h>
29#include <qradiobutton.h> 29#include <qradiobutton.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31#include <qcheckbox.h> 31#include <qcheckbox.h>
32#include <qtabwidget.h> 32#include <qtabwidget.h>
33#include <qcombobox.h> 33#include <qcombobox.h>
34#include <qlistview.h> 34#include <qlistview.h>
35#include <qvbox.h> 35#include <qvbox.h>
36#include <qprogressbar.h> 36#include <qprogressbar.h>
37 37
38/* STD */ 38/* STD */
39#include <assert.h> 39#include <assert.h>
40#include <errno.h> 40#include <errno.h>
41#include <string.h> 41#include <string.h>
42 42
43#define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" 43#define WIRELESS_OPTS "/etc/pcmcia/wireless.opts"
44#define PREUP "/etc/network/if-pre-up.d/wireless-tools" 44#define PREUP "/etc/network/if-pre-up.d/wireless-tools"
45 45
46/** 46/**
47 * Constructor, read in the wireless.opts file for parsing later. 47 * Constructor, read in the wireless.opts file for parsing later.
48 */ 48 */
49WLANImp::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("*") {
50 interfaces = new Interfaces(); 50 interfaces = new Interfaces();
51 interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, interfaces); 51 interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, interfaces);
52 tabWidget->insertTab(interfaceSetup, "TCP/IP"); 52 tabWidget->insertTab(interfaceSetup, "TCP/IP");
53 53
54 // 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
55 QFile file(QString(PREUP)); 55 QFile file(QString(PREUP));
56 if (file.exists()) { 56 if (file.exists()) {
57 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;
58 } 58 }
59 59
60 connect( rescanButton, SIGNAL( clicked() ), this, SLOT( rescanNeighbourhood() ) ); 60 connect( rescanButton, SIGNAL( clicked() ), this, SLOT( rescanNeighbourhood() ) );
61 connect( netView, SIGNAL( clicked(QListViewItem*) ), this, SLOT( selectNetwork(QListViewItem*) ) ); 61 connect( netView, SIGNAL( clicked(QListViewItem*) ), this, SLOT( selectNetwork(QListViewItem*) ) );
62 netView->setColumnAlignment( col_chn, AlignCenter ); 62 netView->setColumnAlignment( col_chn, AlignCenter );
63 netView->setItemMargin( 3 ); 63 netView->setItemMargin( 3 );
64 netView->setAllColumnsShowFocus( true ); 64 netView->setAllColumnsShowFocus( true );
65 65
66} 66}
67 67
68WLANImp::~WLANImp() { 68WLANImp::~WLANImp() {
69//FIXME: delete interfaces; 69//FIXME: delete interfaces;
70} 70}
71 71
72/** 72/**
73 * Change the profile for both wireless settings and network settings. 73 * Change the profile for both wireless settings and network settings.
74 */ 74 */
75void WLANImp::setProfile(const QString &profile){ 75void WLANImp::setProfile(const QString &profile){
76 interfaceSetup->setProfile(profile); 76 interfaceSetup->setProfile(profile);
77 parseOpts(); 77 parseOpts();
78} 78}
79 79
80void WLANImp::parseOpts() { 80void WLANImp::parseOpts() {
81 bool error; 81 bool error;
82 QString opt; 82 QString opt;
83 83
84 if (! interfaces->isInterfaceSet()) 84 if (! interfaces->isInterfaceSet())
85 return; 85 return;
86 86
87 87
88 opt = interfaces->getInterfaceOption("wireless_essid", error); 88 opt = interfaces->getInterfaceOption("wireless_essid", error);
89 if(opt == "any" || opt == "off" || opt.isNull()){ 89 if(opt == "any" || opt == "off" || opt.isNull()){
90 essid->setEditText("any"); 90 essid->setEditText("any");
91 } else { 91 } else {
92 essid->setEditText(opt); 92 essid->setEditText(opt);
93 } 93 }
94 94
95 opt = interfaces->getInterfaceOption("wireless_mode", error).simplifyWhiteSpace(); 95 opt = interfaces->getInterfaceOption("wireless_mode", error).simplifyWhiteSpace();
96 96
97 for ( int i = 0; i < mode->count(); i++) 97 for ( int i = 0; i < mode->count(); i++)
98 if ( mode->text( i ) == opt ) mode->setCurrentItem( i ); 98 if ( mode->text( i ) == opt ) mode->setCurrentItem( i );
99 99
100 opt = interfaces->getInterfaceOption("wireless_ap", error).simplifyWhiteSpace(); 100 opt = interfaces->getInterfaceOption("wireless_ap", error).simplifyWhiteSpace();
101 if (! opt.isNull()) { 101 if (! opt.isNull()) {
102 specifyAp->setChecked(true); 102 specifyAp->setChecked(true);
103 macEdit->setText(opt); 103 macEdit->setText(opt);
104 } 104 }
105 105
106 opt = interfaces->getInterfaceOption("wireless_channel", error).simplifyWhiteSpace(); 106 opt = interfaces->getInterfaceOption("wireless_channel", error).simplifyWhiteSpace();
107 if (! opt.isNull()) { 107 if (! opt.isNull()) {
108 specifyChan->setChecked(true); 108 specifyChan->setChecked(true);
109 networkChannel->setValue(opt.toInt()); 109 networkChannel->setValue(opt.toInt());
110 } 110 }
111 111
112 opt = interfaces->getInterfaceOption("wireless_key", error).simplifyWhiteSpace(); 112 opt = interfaces->getInterfaceOption("wireless_key", error).simplifyWhiteSpace();
113 if (opt.isNull()) 113 if (opt.isNull())
114 opt = interfaces->getInterfaceOption("wireless_enc", error).simplifyWhiteSpace(); 114 opt = interfaces->getInterfaceOption("wireless_enc", error).simplifyWhiteSpace();
115 parseKeyStr(opt); 115 parseKeyStr(opt);
116} 116}
117 117
118void WLANImp::parseKeyStr(QString keystr) { 118void WLANImp::parseKeyStr(QString keystr) {
119 int loc = 0;
120 int index = 1; 119 int index = 1;
121 QString key; 120 QString key;
122 QStringList keys = QStringList::split(QRegExp("\\s+"), keystr); 121 QStringList keys = QStringList::split(QRegExp("\\s+"), keystr);
123 int enc = -1; // encryption state 122 int enc = -1; // encryption state
124 123
125 for (QStringList::Iterator it = keys.begin(); it != keys.end(); ++it) { 124 for (QStringList::Iterator it = keys.begin(); it != keys.end(); ++it) {
126 if ((*it).left(3) == "off") { 125 if ((*it).left(3) == "off") {
127 // encryption disabled 126 // encryption disabled
128 enc = 0; 127 enc = 0;
129 } else if ((*it).left(2) == "on") { 128 } else if ((*it).left(2) == "on") {
130 // encryption enabled 129 // encryption enabled
131 enc = 1; 130 enc = 1;
132 } else if ((*it).left(4) == "open") { 131 } else if ((*it).left(4) == "open") {
133 // open mode, accept non encrypted packets 132 // open mode, accept non encrypted packets
134 acceptNonEnc->setChecked(true); 133 acceptNonEnc->setChecked(true);
135 } else if ((*it).left(10) == "restricted") { 134 } else if ((*it).left(10) == "restricted") {
136 // restricted mode, only accept encrypted packets 135 // restricted mode, only accept encrypted packets
137 rejectNonEnc->setChecked(true); 136 rejectNonEnc->setChecked(true);
138 } else if ((*it).left(3) == "key") { 137 } else if ((*it).left(3) == "key") {
139 // new set of options 138 // new set of options
140 } else if ((*it).left(1) == "[") { 139 } else if ((*it).left(1) == "[") {
141 index = (*it).mid(1, 1).toInt(); 140 index = (*it).mid(1, 1).toInt();
142 // switch current key to index 141 // switch current key to index
143 switch (index) { 142 switch (index) {
144 case 1: 143 case 1:
145 keyRadio0->setChecked(true); 144 keyRadio0->setChecked(true);
146 break; 145 break;
147 case 2: 146 case 2:
148 keyRadio1->setChecked(true); 147 keyRadio1->setChecked(true);
149 break; 148 break;
150 case 3: 149 case 3:
151 keyRadio2->setChecked(true); 150 keyRadio2->setChecked(true);
152 break; 151 break;
153 case 4: 152 case 4:
154 keyRadio3->setChecked(true); 153 keyRadio3->setChecked(true);
155 break; 154 break;
156 } 155 }
157 } else { 156 } else {
158 // key 157 // key
159 key = (*it); 158 key = (*it);
160 } 159 }
161 if (! key.isNull()) { 160 if (! key.isNull()) {
162 if (enc == -1) 161 if (enc == -1)
163 enc = 1; 162 enc = 1;
164 QStringList::Iterator next = ++it; 163 QStringList::Iterator next = ++it;
165 if (it == keys.end()) { 164 if (it == keys.end()) {
166 break; 165 break;
167 } 166 }
168 if ((*(next)).left(1) == "[") { 167 if ((*(next)).left(1) == "[") {
169 // set key at index 168 // set key at index
170 index = (*(next)).mid(1, 1).toInt(); 169 index = (*(next)).mid(1, 1).toInt();
171 } else { 170 } else {
172 index = 1; 171 index = 1;
173 } 172 }
174 switch (index) { 173 switch (index) {
175 case 1: 174 case 1:
176 keyLineEdit0->setText(key); 175 keyLineEdit0->setText(key);
177 break; 176 break;
178 case 2: 177 case 2:
179 keyLineEdit1->setText(key); 178 keyLineEdit1->setText(key);
180 break; 179 break;
181 case 3: 180 case 3:
182 keyLineEdit2->setText(key); 181 keyLineEdit2->setText(key);
183 break; 182 break;
184 case 4: 183 case 4:
185 keyLineEdit3->setText(key); 184 keyLineEdit3->setText(key);
186 break; 185 break;
187 } 186 }
188 key = QString::null; 187 key = QString::null;
189 } 188 }
190 } 189 }
191 if (enc == 1) { 190 if (enc == 1) {
192 wepEnabled->setChecked(true); 191 wepEnabled->setChecked(true);
193 } else { 192 } else {
194 wepEnabled->setChecked(false); 193 wepEnabled->setChecked(false);
195 } 194 }
196} 195}
197 196
198/** 197/**
199 * Check to see if the current config is valid 198 * Check to see if the current config is valid
200 * Save interfaces 199 * Save interfaces
201 */ 200 */
202void WLANImp::accept() { 201void WLANImp::accept() {
203 if (wepEnabled->isChecked()) { 202 if (wepEnabled->isChecked()) {
204 if ((keyRadio0->isChecked() && keyLineEdit0->text().isEmpty()) || 203 if ((keyRadio0->isChecked() && keyLineEdit0->text().isEmpty()) ||
205 (keyRadio1->isChecked() && keyLineEdit1->text().isEmpty()) || 204 (keyRadio1->isChecked() && keyLineEdit1->text().isEmpty()) ||
206 (keyRadio2->isChecked() && keyLineEdit2->text().isEmpty()) || 205 (keyRadio2->isChecked() && keyLineEdit2->text().isEmpty()) ||
207 (keyRadio3->isChecked() && keyLineEdit3->text().isEmpty())) { 206 (keyRadio3->isChecked() && keyLineEdit3->text().isEmpty())) {
208 QMessageBox::information(this, "Error", "Please enter a WEP key.", QMessageBox::Ok); 207 QMessageBox::information(this, "Error", "Please enter a WEP key.", QMessageBox::Ok);
209 return; 208 return;
210 } 209 }
211 } 210 }
212 211
213 if (essid->currentText().isEmpty()) { 212 if (essid->currentText().isEmpty()) {
214 QMessageBox::information(this, "Error", "Please select/enter an ESSID.", QMessageBox::Ok); 213 QMessageBox::information(this, "Error", "Please select/enter an ESSID.", QMessageBox::Ok);
215 return; 214 return;
216 } 215 }
217 216
218 if (specifyAp->isChecked() && macEdit->text().isEmpty()) { 217 if (specifyAp->isChecked() && macEdit->text().isEmpty()) {
219 QMessageBox::information(this, "Error", "Please enter the MAC address of the Access Point.", QMessageBox::Ok); 218 QMessageBox::information(this, "Error", "Please enter the MAC address of the Access Point.", QMessageBox::Ok);
220 return; 219 return;
221 } 220 }
222 221
223 // Try to save the interfaces settings. 222 // Try to save the interfaces settings.
224 writeOpts(); 223 writeOpts();
225 224
226 // Close out the dialog 225 // Close out the dialog
227// FIXME: QDialog::accept(); 226// FIXME: QDialog::accept();
228} 227}
229 228
230void WLANImp::writeOpts() { 229void WLANImp::writeOpts() {
231 // eh can't really do anything about it other then return. :-D 230 // eh can't really do anything about it other then return. :-D
232 if(!interfaces->isInterfaceSet()){ 231 if(!interfaces->isInterfaceSet()){
233 QMessageBox::warning(0,"Inface not set","should not happen!!!"); 232 QMessageBox::warning(0,"Inface not set","should not happen!!!");
234 return; 233 return;
235 } 234 }
236 bool error = false; 235 bool error = false;
237 236
238 odebug << "setting wlan interface " << interfaces->getInterfaceName( error ).latin1() << "" << oendl; 237 odebug << "setting wlan interface " << interfaces->getInterfaceName( error ).latin1() << "" << oendl;
239 238
240 if (error) QMessageBox::warning(0,"Inface not set","should not happen!!!"); 239 if (error) QMessageBox::warning(0,"Inface not set","should not happen!!!");
241 240
242 interfaces->setInterfaceOption(QString("wireless_mode"), mode->currentText()); 241 interfaces->setInterfaceOption(QString("wireless_mode"), mode->currentText());
243 interfaces->setInterfaceOption(QString("wireless_essid"), essid->currentText()); 242 interfaces->setInterfaceOption(QString("wireless_essid"), essid->currentText());
244 243
245 if (specifyAp->isChecked()) { 244 if (specifyAp->isChecked()) {
246 interfaces->setInterfaceOption(QString("wireless_ap"), macEdit->text()); 245 interfaces->setInterfaceOption(QString("wireless_ap"), macEdit->text());
247 } else { 246 } else {
248 interfaces->removeInterfaceOption(QString("wireless_ap")); 247 interfaces->removeInterfaceOption(QString("wireless_ap"));
249 } 248 }
250 249
251 if (specifyChan->isChecked()) { 250 if (specifyChan->isChecked()) {
252 interfaces->setInterfaceOption(QString("wireless_channel"), networkChannel->text()); 251 interfaces->setInterfaceOption(QString("wireless_channel"), networkChannel->text());
253 } else { 252 } else {
254 interfaces->removeInterfaceOption(QString("wireless_channel")); 253 interfaces->removeInterfaceOption(QString("wireless_channel"));
255 } 254 }
256 255
257 if (wepEnabled->isChecked()) { 256 if (wepEnabled->isChecked()) {
258 QStringList keyList; 257 QStringList keyList;
259 258
260 if (! keyLineEdit0->text().isNull()) { 259 if (! keyLineEdit0->text().isNull()) {
261 keyList += keyLineEdit0->text(); 260 keyList += keyLineEdit0->text();
262 keyList += "[1]"; 261 keyList += "[1]";
263 } //else 262 } //else
264 if (! keyLineEdit1->text().isNull()) { 263 if (! keyLineEdit1->text().isNull()) {
265 keyList += keyLineEdit1->text(); 264 keyList += keyLineEdit1->text();
266 keyList += "[2]"; 265 keyList += "[2]";
267 } //else 266 } //else
268 if (! keyLineEdit2->text().isNull()) { 267 if (! keyLineEdit2->text().isNull()) {
269 keyList += keyLineEdit2->text(); 268 keyList += keyLineEdit2->text();
270 keyList += "[3]"; 269 keyList += "[3]";
271 } //else 270 } //else
272 if (! keyLineEdit3->text().isNull()) { 271 if (! keyLineEdit3->text().isNull()) {
273 keyList += keyLineEdit3->text(); 272 keyList += keyLineEdit3->text();
274 keyList += "[4]"; 273 keyList += "[4]";
275 } 274 }
276 if (acceptNonEnc->isChecked()) { 275 if (acceptNonEnc->isChecked()) {
277 keyList += "open"; 276 keyList += "open";
278 } else { 277 } else {
279 keyList += "restricted"; 278 keyList += "restricted";
280 } 279 }
281 280
282 keyList += "key"; 281 keyList += "key";
283 if (keyRadio0->isChecked()) { 282 if (keyRadio0->isChecked()) {
284 keyList += "[1]"; 283 keyList += "[1]";
285 } else if (keyRadio1->isChecked()) { 284 } else if (keyRadio1->isChecked()) {
286 keyList += "[2]"; 285 keyList += "[2]";
287 } else if (keyRadio2->isChecked()) { 286 } else if (keyRadio2->isChecked()) {
288 keyList += "[3]"; 287 keyList += "[3]";
289 } else if (keyRadio3->isChecked()) { 288 } else if (keyRadio3->isChecked()) {
290 keyList += "[4]"; 289 keyList += "[4]";
291 } 290 }
292 interfaces->setInterfaceOption(QString("wireless_key"), keyList.join(QString(" "))); 291 interfaces->setInterfaceOption(QString("wireless_key"), keyList.join(QString(" ")));
293 } else { 292 } else {
294 interfaces->removeInterfaceOption(QString("wireless_key")); 293 interfaces->removeInterfaceOption(QString("wireless_key"));
295 } 294 }
296 interfaces->removeInterfaceOption(QString("wireless_enc")); 295 interfaces->removeInterfaceOption(QString("wireless_enc"));
297 296
298 if(!interfaceSetup->saveChanges()) 297 if(!interfaceSetup->saveChanges())
299 return; 298 return;
300 299
301 QDialog::accept(); 300 QDialog::accept();
302} 301}
303 302
304/* 303/*
305 * Scan for possible wireless networks around... 304 * Scan for possible wireless networks around...
306 * ... powered by Wellenreiter II technology (C) Michael 'Mickey' Lauer <mickeyl@handhelds.org> 305 * ... powered by Wellenreiter II technology (C) Michael 'Mickey' Lauer <mickeyl@handhelds.org>
307 */ 306 */
308 307
309void WLANImp::rescanNeighbourhood() 308void WLANImp::rescanNeighbourhood()
310{ 309{
311 QString name = interface->getInterfaceName(); 310 QString name = interface->getInterfaceName();
312 odebug << "rescanNeighbourhood via '" << name << "'" << oendl; 311 odebug << "rescanNeighbourhood via '" << name << "'" << oendl;
313 312
314 OWirelessNetworkInterface* wiface = static_cast<OWirelessNetworkInterface*>( ONetwork::instance()->interface( name ) ); 313 OWirelessNetworkInterface* wiface = static_cast<OWirelessNetworkInterface*>( ONetwork::instance()->interface( name ) );
315 assert( wiface ); 314 assert( wiface );
316 315
317 // try to guess device type 316 // try to guess device type
318 QString devicetype; 317 QString devicetype;
319 QFile m( "/proc/modules" ); 318 QFile m( "/proc/modules" );
320 if ( m.open( IO_ReadOnly ) ) 319 if ( m.open( IO_ReadOnly ) )
321 { 320 {
322 QString line; 321 QString line;
323 QTextStream modules( &m ); 322 QTextStream modules( &m );
324 while( !modules.atEnd() && !devicetype ) 323 while( !modules.atEnd() && !devicetype )
325 { 324 {
326 modules >> line; 325 modules >> line;
327 if ( line.contains( "cisco" ) ) devicetype = "cisco"; 326 if ( line.contains( "cisco" ) ) devicetype = "cisco";
328 else if ( line.contains( "hostap" ) ) devicetype = "hostap"; 327 else if ( line.contains( "hostap" ) ) devicetype = "hostap";
329 else if ( line.contains( "prism" ) ) devicetype = "wlan-ng"; /* puke */ 328 else if ( line.contains( "prism" ) ) devicetype = "wlan-ng"; /* puke */
330 else if ( line.contains( "orinoco" ) ) devicetype = "orinoco"; 329 else if ( line.contains( "orinoco" ) ) devicetype = "orinoco";
331 } 330 }
332 } 331 }
333 if ( devicetype.isEmpty() ) 332 if ( devicetype.isEmpty() )
334 { 333 {
335 owarn << "rescanNeighbourhood(): couldn't guess device type :(" << oendl; 334 owarn << "rescanNeighbourhood(): couldn't guess device type :(" << oendl;
336 return; 335 return;
337 } 336 }
338 else 337 else
339 { 338 {
340 odebug << "rescanNeighbourhood(): device type seems to be '" << devicetype << "'" << oendl; 339 odebug << "rescanNeighbourhood(): device type seems to be '" << devicetype << "'" << oendl;
341 } 340 }
342 341
343 // configure interface to receive 802.11 management frames 342 // configure interface to receive 802.11 management frames
344 343
345 wiface->setUp( true ); 344 wiface->setUp( true );
346 wiface->setPromiscuousMode( true ); 345 wiface->setPromiscuousMode( true );
347 346
348 if ( devicetype == "cisco" ) wiface->setMonitoring( new OCiscoMonitoringInterface( wiface, false ) ); 347 if ( devicetype == "cisco" ) wiface->setMonitoring( new OCiscoMonitoringInterface( wiface, false ) );
349 else if ( devicetype == "hostap" ) wiface->setMonitoring( new OHostAPMonitoringInterface( wiface, false ) ); 348 else if ( devicetype == "hostap" ) wiface->setMonitoring( new OHostAPMonitoringInterface( wiface, false ) );
350 else if ( devicetype == "wlan-ng" ) wiface->setMonitoring( new OWlanNGMonitoringInterface( wiface, false ) ); 349 else if ( devicetype == "wlan-ng" ) wiface->setMonitoring( new OWlanNGMonitoringInterface( wiface, false ) );
351 else if ( devicetype == "orinoco" ) wiface->setMonitoring( new OOrinocoMonitoringInterface( wiface, false ) ); 350 else if ( devicetype == "orinoco" ) wiface->setMonitoring( new OOrinocoMonitoringInterface( wiface, false ) );
352 else 351 else
353 { 352 {
354 odebug << "rescanNeighbourhood(): unsupported device type for monitoring :(" << oendl; 353 odebug << "rescanNeighbourhood(): unsupported device type for monitoring :(" << oendl;
355 return; 354 return;
356 } 355 }
357 356
358 wiface->setMode( "monitor" ); 357 wiface->setMode( "monitor" );
359 if ( wiface->mode() != "monitor" ) 358 if ( wiface->mode() != "monitor" )
360 { 359 {
361 owarn << "rescanNeighbourhood(): Unable to bring device into monitor mode (" << strerror( errno ) << ")." << oendl; 360 owarn << "rescanNeighbourhood(): Unable to bring device into monitor mode (" << strerror( errno ) << ")." << oendl;
362 return; 361 return;
363 } 362 }
364 363
365 // open a packet capturer 364 // open a packet capturer
366 OPacketCapturer* cap = new OPacketCapturer(); 365 OPacketCapturer* cap = new OPacketCapturer();
367 cap->open( name ); 366 cap->open( name );
368 if ( !cap->isOpen() ) 367 if ( !cap->isOpen() )
369 { 368 {
370 owarn << "rescanNeighbourhood(): Unable to open libpcap (" << strerror( errno ) << ")." << oendl; 369 owarn << "rescanNeighbourhood(): Unable to open libpcap (" << strerror( errno ) << ")." << oendl;
371 return; 370 return;
372 } 371 }
373 372
374 // display splash screen 373 // display splash screen
375 QFrame* splash = new QFrame( this, "splash", false, WStyle_StaysOnTop | WStyle_DialogBorder | WStyle_Customize ); 374 QFrame* splash = new QFrame( this, "splash", false, WStyle_StaysOnTop | WStyle_DialogBorder | WStyle_Customize );
376 splash->setLineWidth( 2 ); 375 splash->setLineWidth( 2 );
377 splash->setFrameStyle( QFrame::Panel | QFrame::Raised ); 376 splash->setFrameStyle( QFrame::Panel | QFrame::Raised );
378 QVBoxLayout* vbox = new QVBoxLayout( splash, 4, 4 ); 377 QVBoxLayout* vbox = new QVBoxLayout( splash, 4, 4 );
379 QLabel* lab = new QLabel( "<center><b>Scanning...</b><br>Please Wait...</center>", splash ); 378 QLabel* lab = new QLabel( "<center><b>Scanning...</b><br>Please Wait...</center>", splash );
380 QProgressBar* pb = new QProgressBar( wiface->channels(), splash ); 379 QProgressBar* pb = new QProgressBar( wiface->channels(), splash );
381 vbox->addWidget( lab ); 380 vbox->addWidget( lab );
382 vbox->addWidget( pb ); 381 vbox->addWidget( pb );
383 pb->setCenterIndicator( true ); 382 pb->setCenterIndicator( true );
384 pb->setFixedHeight( pb->sizeHint().height() ); 383 pb->setFixedHeight( pb->sizeHint().height() );
385 QWidget* widgetDesktop = qApp->desktop(); 384 QWidget* widgetDesktop = qApp->desktop();
386 int dw = widgetDesktop->width(); 385 int dw = widgetDesktop->width();
387 int dh = widgetDesktop->height(); 386 int dh = widgetDesktop->height();
388 int pw = vbox->sizeHint().width(); 387 int pw = vbox->sizeHint().width();
389 int ph = vbox->sizeHint().height(); 388 int ph = vbox->sizeHint().height();
390 splash->setGeometry((dw-pw)/2,(dh-ph)/2,pw,ph); 389 splash->setGeometry((dw-pw)/2,(dh-ph)/2,pw,ph);
391 splash->show(); 390 splash->show();
392 splash->raise(); 391 splash->raise();
393 qApp->processEvents(); 392 qApp->processEvents();
394 393
395 // set capturer to non-blocking mode 394 // set capturer to non-blocking mode
396 cap->setBlocking( false ); 395 cap->setBlocking( false );
397 396
398 for ( int i = 1; i <= wiface->channels(); ++i ) 397 for ( int i = 1; i <= wiface->channels(); ++i )
399 { 398 {
400 wiface->setChannel( i ); 399 wiface->setChannel( i );
401 pb->setProgress( i ); 400 pb->setProgress( i );
402 qApp->processEvents(); 401 qApp->processEvents();
403 odebug << "rescanNeighbourhood(): listening on channel " << i << "..." << oendl; 402 odebug << "rescanNeighbourhood(): listening on channel " << i << "..." << oendl;
404 OPacket* p = cap->next( 1000 ); 403 OPacket* p = cap->next( 1000 );
405 if ( !p ) 404 if ( !p )
406 { 405 {
407 odebug << "rescanNeighbourhood(): nothing received on channel " << i << "" << oendl; 406 odebug << "rescanNeighbourhood(): nothing received on channel " << i << "" << oendl;
408 } 407 }
409 else 408 else
410 { 409 {
411 odebug << "rescanNeighbourhood(): TADAA - something came in on channel " << i << "" << oendl; 410 odebug << "rescanNeighbourhood(): TADAA - something came in on channel " << i << "" << oendl;
412 handlePacket( p ); 411 handlePacket( p );
413 } 412 }
414 } 413 }
415 414
416 cap->close(); 415 cap->close();
417 wiface->setMode( "managed" ); // TODO: use previous mode 416 wiface->setMode( "managed" ); // TODO: use previous mode
418 wiface->setPromiscuousMode( false ); 417 wiface->setPromiscuousMode( false );
419 418
420 splash->hide(); 419 splash->hide();
421 delete splash; 420 delete splash;
422 421
423} 422}
424 423
425void WLANImp::handlePacket( OPacket* p ) 424void WLANImp::handlePacket( OPacket* p )
426{ 425{
427 426
428 // check if we received a beacon frame 427 // check if we received a beacon frame
429 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); 428 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) );
430 if ( beacon && beacon->managementType() == "Beacon" ) 429 if ( beacon && beacon->managementType() == "Beacon" )
431 { 430 {
432 431
433 QString type; 432 QString type;
434 if ( beacon->canIBSS() ) 433 if ( beacon->canIBSS() )
435 { 434 {
436 type = "adhoc"; 435 type = "adhoc";
437 } 436 }
438 else if ( beacon->canESS() ) 437 else if ( beacon->canESS() )
439 { 438 {
440 type = "managed"; 439 type = "managed";
441 } 440 }
442 else 441 else
443 { 442 {
444 owarn << "handlePacket(): invalid frame [possibly noise] detected!" << oendl; 443 owarn << "handlePacket(): invalid frame [possibly noise] detected!" << oendl;
445 return; 444 return;
446 } 445 }
447 446
448 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); 447 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
449 QString essid = ssid ? ssid->ID() : QString("<unknown>"); 448 QString essid = ssid ? ssid->ID() : QString("<unknown>");
450 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); 449 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
451 int channel = ds ? ds->channel() : -1; 450 int channel = ds ? ds->channel() : -1;
452 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 451 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
453 displayFoundNetwork( type, channel, essid, header->macAddress2() ); 452 displayFoundNetwork( type, channel, essid, header->macAddress2() );
454 } 453 }
455} 454}
456 455
457 456
458void WLANImp::displayFoundNetwork( const QString& mode, int channel, const QString& ssid, const OMacAddress& mac ) 457void WLANImp::displayFoundNetwork( const QString& mode, int channel, const QString& ssid, const OMacAddress& mac )
459{ 458{
460 459
461 odebug << "found network: <" << (const char*) mode << ">, chn " << channel 460 odebug << "found network: <" << (const char*) mode << ">, chn " << channel
462 << ", ssid '" << (const char*) ssid << "', mac '" << (const char*) mac.toString() << "'" << oendl; 461 << ", ssid '" << (const char*) ssid << "', mac '" << (const char*) mac.toString() << "'" << oendl;
463 462
464 QListViewItemIterator it( netView ); 463 QListViewItemIterator it( netView );
465 while ( it.current() && it.current()->text( col_ssid ) != ssid ) ++it; 464 while ( it.current() && it.current()->text( col_ssid ) != ssid ) ++it;
466 if ( !it.current() ) // ssid didn't show up yet 465 if ( !it.current() ) // ssid didn't show up yet
467 { 466 {
468 QListViewItem* item = new QListViewItem( netView, mode.left( 1 ).upper(), ssid, QString::number( channel ), mac.toString() ); 467 QListViewItem* item = new QListViewItem( netView, mode.left( 1 ).upper(), ssid, QString::number( channel ), mac.toString() );
469 QString name; 468 QString name;
470 name.sprintf( "networksettings/%s", (const char*) mode ); 469 name.sprintf( "networksettings/%s", (const char*) mode );
471 item->setPixmap( col_mode, Resource::loadPixmap( name ) ); 470 item->setPixmap( col_mode, Resource::loadPixmap( name ) );
472 qApp->processEvents(); 471 qApp->processEvents();
473 } 472 }
474 473
475} 474}
476 475
477 476
478void WLANImp::selectNetwork( QListViewItem* item ) 477void WLANImp::selectNetwork( QListViewItem* item )
479{ 478{
480 bool ok; 479 bool ok;
481 if ( item ) 480 if ( item )
482 { 481 {
483 specifyAp->setChecked(true); 482 specifyAp->setChecked(true);
484 macEdit->setText( item->text( col_mac ) ); 483 macEdit->setText( item->text( col_mac ) );
485 specifyChan->setChecked( item->text( col_mode ) == "A" ); 484 specifyChan->setChecked( item->text( col_mode ) == "A" );
486 networkChannel->setValue( item->text( col_chn ).toInt( &ok ) ); 485 networkChannel->setValue( item->text( col_chn ).toInt( &ok ) );
487 essid->setEditText( item->text( col_ssid ) ); 486 essid->setEditText( item->text( col_ssid ) );
488 if ( item->text( col_mode ) == "A" ) 487 if ( item->text( col_mode ) == "A" )
489 mode->setCurrentItem( 3 ); 488 mode->setCurrentItem( 3 );
490 else 489 else
491 mode->setCurrentItem( 2 ); 490 mode->setCurrentItem( 2 );
492 } 491 }
493} 492}