summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/connect.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/noncore/settings/networksettings/ppp/connect.cpp b/noncore/settings/networksettings/ppp/connect.cpp
index 6905d79..2400d7b 100644
--- a/noncore/settings/networksettings/ppp/connect.cpp
+++ b/noncore/settings/networksettings/ppp/connect.cpp
@@ -1,244 +1,247 @@
1/* 1/*
2 * kPPP: A pppd front end for the KDE project 2 * kPPP: A pppd front end for the KDE project
3 * 3 *
4 * 4 *
5 * Copyright (C) 1997 Bernd Johannes Wuebben 5 * Copyright (C) 1997 Bernd Johannes Wuebben
6 * wuebben@math.cornell.edu 6 * wuebben@math.cornell.edu
7 * Copyright (C) 1998-2001 Harri Porten <porten@kde.org> 7 * Copyright (C) 1998-2001 Harri Porten <porten@kde.org>
8 * 8 *
9 * based on EzPPP: 9 * based on EzPPP:
10 * Copyright (C) 1997 Jay Painter 10 * Copyright (C) 1997 Jay Painter
11 * 11 *
12 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Library General Public 13 * modify it under the terms of the GNU Library General Public
14 * License as published by the Free Software Foundation; either 14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version. 15 * version 2 of the License, or (at your option) any later version.
16 * 16 *
17 * This program is distributed in the hope that it will be useful, 17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details. 20 * Library General Public License for more details.
21 * 21 *
22 * You should have received a copy of the GNU Library General Public 22 * You should have received a copy of the GNU Library General Public
23 * License along with this program; if not, write to the Free 23 * License along with this program; if not, write to the Free
24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */ 25 */
26 26
27//#include <config.h> 27//#include <config.h>
28 28
29#include <qlayout.h> 29#include <qlayout.h>
30#include <qregexp.h> 30#include <qregexp.h>
31 31
32#include <qapplication.h> 32#include <qapplication.h>
33//#include <kdebug.h> 33//#include <kdebug.h>
34//#include <klocale.h> 34//#include <klocale.h>
35#define i18n QObject::tr 35#define i18n QObject::tr
36#include <qmessagebox.h> 36#include <qmessagebox.h>
37#include <qpushbutton.h> 37#include <qpushbutton.h>
38 38
39#include <unistd.h> 39#include <unistd.h>
40#include <stdlib.h> 40#include <stdlib.h>
41#include <string.h> 41#include <string.h>
42#include <fcntl.h> 42#include <fcntl.h>
43#include <netdb.h> 43#include <netdb.h>
44#include <sys/types.h> 44#include <sys/types.h>
45#include <sys/socket.h> 45#include <sys/socket.h>
46#include <arpa/inet.h> 46#include <arpa/inet.h>
47#include <netinet/in.h> 47#include <netinet/in.h>
48#include <sys/ioctl.h> 48#include <sys/ioctl.h>
49#include <assert.h> 49#include <assert.h>
50 50
51#ifdef _XPG4_2 51#ifdef _XPG4_2
52 #define __xnet_connectconnect 52 #define __xnet_connectconnect
53#endif 53#endif
54 54
55#include <errno.h> 55#include <errno.h>
56 56
57#ifdef HAVE_SYS_PARAM_H 57#ifdef HAVE_SYS_PARAM_H
58#include <sys/param.h> 58#include <sys/param.h>
59#endif 59#endif
60 60
61#ifdef __linux__ 61#ifdef __linux__
62#include "runtests.h" 62#include "runtests.h"
63#endif 63#endif
64 64
65#include "auth.h" 65#include "auth.h"
66#include "connect.h" 66#include "connect.h"
67//#include "docking.h" 67//#include "docking.h"
68#include "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 = i18n("Connecting to: "); 102 QString tit = i18n("Connecting to: ");
103 setCaption(tit); 103 setCaption(tit);
104 104
105 QHBoxLayout *l0 = new QHBoxLayout(10); 105 QHBoxLayout *l0 = new QHBoxLayout(10);
106 tl->addLayout(l0); 106 tl->addLayout(l0);
107 l0->addSpacing(10); 107 l0->addSpacing(10);
108 messg = new QLabel(this, "messg"); 108 messg = new QLabel(this, "messg");
109 messg->setFrameStyle(QFrame::Panel|QFrame::Sunken); 109 messg->setFrameStyle(QFrame::Panel|QFrame::Sunken);
110 messg->setAlignment(AlignCenter); 110 messg->setAlignment(AlignCenter);
111 messg->setText(i18n("Unable to create modem lock file.")); 111 messg->setText(i18n("Unable to create modem lock file."));
112 messg->setMinimumHeight(messg->sizeHint().height() + 5); 112 messg->setMinimumHeight(messg->sizeHint().height() + 5);
113// int messw = (messg->sizeHint().width() * 12) / 10; 113// int messw = (messg->sizeHint().width() * 12) / 10;
114// messw = QMAX(messw,280); 114// messw = QMAX(messw,280);
115// messg->setMinimumWidth(messw); 115// messg->setMinimumWidth(messw);
116 messg->setText(i18n("Offline")); 116 if (_ifaceppp->getStatus())
117 messg->setText(i18n("Online"));
118 else
119 messg->setText(i18n("Offline"));
117 l0->addSpacing(10); 120 l0->addSpacing(10);
118 l0->addWidget(messg); 121 l0->addWidget(messg);
119 l0->addSpacing(10); 122 l0->addSpacing(10);
120 123
121 QHBoxLayout *l1 = new QHBoxLayout(10); 124 QHBoxLayout *l1 = new QHBoxLayout(10);
122 tl->addLayout(l1); 125 tl->addLayout(l1);
123 l1->addStretch(1); 126 l1->addStretch(1);
124 127
125 debug = new QPushButton(i18n("Log"), this); 128 debug = new QPushButton(i18n("Log"), this);
126 debug->setToggleButton(true); 129 debug->setToggleButton(true);
127 debug->setEnabled( false ); // FIXME: disable the log button 130 debug->setEnabled( false ); // FIXME: disable the log button
128 connect(debug, SIGNAL(clicked()), SIGNAL(toggleDebugWindow())); 131 connect(debug, SIGNAL(clicked()), SIGNAL(toggleDebugWindow()));
129 132
130 cancel = new QPushButton(i18n("Cancel"), this); 133 cancel = new QPushButton(i18n("Cancel"), this);
131 cancel->setFocus(); 134 cancel->setFocus();
132 connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton())); 135 connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton()));
133 136
134// int maxw = QMAX(cancel->sizeHint().width(), 137// int maxw = QMAX(cancel->sizeHint().width(),
135 // debug->sizeHint().width()); 138 // debug->sizeHint().width());
136// maxw = QMAX(maxw,65); 139// maxw = QMAX(maxw,65);
137// debug->setFixedWidth(maxw); 140// debug->setFixedWidth(maxw);
138// cancel->setFixedWidth(maxw); 141// cancel->setFixedWidth(maxw);
139 l1->addWidget(debug); 142 l1->addWidget(debug);
140 l1->addWidget(cancel); 143 l1->addWidget(cancel);
141 144
142// setFixedSize(sizeHint()); 145// setFixedSize(sizeHint());
143 146
144 pausetimer = new QTimer(this); 147 pausetimer = new QTimer(this);
145 connect(pausetimer, SIGNAL(timeout()), SLOT(pause())); 148 connect(pausetimer, SIGNAL(timeout()), SLOT(pause()));
146 149
147 qApp->processEvents(); 150 qApp->processEvents();
148 151
149 timeout_timer = new QTimer(this); 152 timeout_timer = new QTimer(this);
150 connect(timeout_timer, SIGNAL(timeout()), SLOT(script_timed_out())); 153 connect(timeout_timer, SIGNAL(timeout()), SLOT(script_timed_out()));
151 154
152 inittimer = new QTimer(this); 155 inittimer = new QTimer(this);
153 connect(inittimer, SIGNAL(timeout()), SLOT(init())); 156 connect(inittimer, SIGNAL(timeout()), SLOT(init()));
154 157
155 if_timeout_timer = new QTimer(this); 158 if_timeout_timer = new QTimer(this);
156 connect(if_timeout_timer, SIGNAL(timeout()), SLOT(if_waiting_timed_out())); 159 connect(if_timeout_timer, SIGNAL(timeout()), SLOT(if_waiting_timed_out()));
157 160
158 connect(this,SIGNAL(if_waiting_signal()),this,SLOT(if_waiting_slot())); 161 connect(this,SIGNAL(if_waiting_signal()),this,SLOT(if_waiting_slot()));
159 162
160 prompt = new PWEntry( this, "pw" ); 163 prompt = new PWEntry( this, "pw" );
161 if_timer = new QTimer(this); 164 if_timer = new QTimer(this);
162 connect(if_timer,SIGNAL(timeout()), SLOT(if_waiting_slot())); 165 connect(if_timer,SIGNAL(timeout()), SLOT(if_waiting_slot()));
163} 166}
164 167
165 168
166ConnectWidget::~ConnectWidget() { 169ConnectWidget::~ConnectWidget() {
167} 170}
168 171
169 172
170void ConnectWidget::preinit() { 173void ConnectWidget::preinit() {
171 // this is all just to keep the GUI nice and snappy .... 174 // this is all just to keep the GUI nice and snappy ....
172 // you have to see to believe ... 175 // you have to see to believe ...
173 messg->setText(i18n("Looking for modem...")); 176 messg->setText(i18n("Looking for modem..."));
174 inittimer->start(100); 177 inittimer->start(100);
175} 178}
176 179
177 180
178void ConnectWidget::init() { 181void ConnectWidget::init() {
179 _ifaceppp->data()->setpppdError(0); 182 _ifaceppp->data()->setpppdError(0);
180 inittimer->stop(); 183 inittimer->stop();
181 vmain = 0; 184 vmain = 0;
182 substate = -1; 185 substate = -1;
183 expecting = false; 186 expecting = false;
184 pausing = false; 187 pausing = false;
185 scriptindex = 0; 188 scriptindex = 0;
186 myreadbuffer = ""; 189 myreadbuffer = "";
187 scanning = false; 190 scanning = false;
188 scanvar = ""; 191 scanvar = "";
189 firstrunID = true; 192 firstrunID = true;
190 firstrunPW = true; 193 firstrunPW = true;
191// stats->totalbytes = 0; 194// stats->totalbytes = 0;
192 dialnumber = 0; 195 dialnumber = 0;
193 196
194// p_kppp->con_speed = ""; 197// p_kppp->con_speed = "";
195 198
196// p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || _ifaceppp->data()->quit_on_disconnect()); 199// p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || _ifaceppp->data()->quit_on_disconnect());
197 200
198 comlist = &_ifaceppp->data()->scriptType(); 201 comlist = &_ifaceppp->data()->scriptType();
199 arglist = &_ifaceppp->data()->script(); 202 arglist = &_ifaceppp->data()->script();
200 203
201 QString tit = i18n("Connecting to: %1").arg(_ifaceppp->data()->accname()); 204 QString tit = i18n("Connecting to: %1").arg(_ifaceppp->data()->accname());
202 setCaption(tit); 205 setCaption(tit);
203 206
204 qApp->processEvents(); 207 qApp->processEvents();
205 208
206 // run the "before-connect" command 209 // run the "before-connect" command
207 if (!_ifaceppp->data()->command_before_connect().isEmpty()) { 210 if (!_ifaceppp->data()->command_before_connect().isEmpty()) {
208 messg->setText(i18n("Running pre-startup command...")); 211 messg->setText(i18n("Running pre-startup command..."));
209 emit debugMessage(i18n("Running pre-startup command...")); 212 emit debugMessage(i18n("Running pre-startup command..."));
210 213
211 qApp->processEvents(); 214 qApp->processEvents();
212 QApplication::flushX(); 215 QApplication::flushX();
213 pid_t id = execute_command(_ifaceppp->data()->command_before_connect()); 216 pid_t id = execute_command(_ifaceppp->data()->command_before_connect());
214// int i, status; 217// int i, status;
215 218
216// do { 219// do {
217// qApp->processEvents(); 220// qApp->processEvents();
218// i = waitpid(id, &status, WNOHANG); 221// i = waitpid(id, &status, WNOHANG);
219// usleep(100000); 222// usleep(100000);
220// } while (i == 0 && errno == 0); 223// } while (i == 0 && errno == 0);
221 } 224 }
222 225
223 int lock = _ifaceppp->modem()->lockdevice(); 226 int lock = _ifaceppp->modem()->lockdevice();
224 227
225 if (lock == 1) { 228 if (lock == 1) {
226 messg->setText(i18n("Modem device is locked.")); 229 messg->setText(i18n("Modem device is locked."));
227 vmain = 20; // wait until cancel is pressed 230 vmain = 20; // wait until cancel is pressed
228 return; 231 return;
229 } 232 }
230 233
231 if (lock == -1) { 234 if (lock == -1) {
232 messg->setText(i18n("Unable to create modem lock file.")); 235 messg->setText(i18n("Unable to create modem lock file."));
233 vmain = 20; // wait until cancel is pressed 236 vmain = 20; // wait until cancel is pressed
234 return; 237 return;
235 } 238 }
236 239
237 if(_ifaceppp->modem()->opentty()) { 240 if(_ifaceppp->modem()->opentty()) {
238 messg->setText(_ifaceppp->modem()->modemMessage()); 241 messg->setText(_ifaceppp->modem()->modemMessage());
239 qApp->processEvents(); 242 qApp->processEvents();
240 if(_ifaceppp->modem()->hangup()) { 243 if(_ifaceppp->modem()->hangup()) {
241 244
242 qApp->processEvents(); 245 qApp->processEvents();
243 246
244 semaphore = false; 247 semaphore = false;
@@ -1007,256 +1010,259 @@ void ConnectWidget::cancelbutton() {
1007 } 1010 }
1008 prompt->setConsumed(); 1011 prompt->setConsumed();
1009 1012
1010 messg->setText(tr("offline")); 1013 messg->setText(tr("offline"));
1011} 1014}
1012 1015
1013 1016
1014void ConnectWidget::script_timed_out() { 1017void ConnectWidget::script_timed_out() {
1015 if(vmain == 20) { // we are in the 'wait for the user to cancel' state 1018 if(vmain == 20) { // we are in the 'wait for the user to cancel' state
1016 timeout_timer->stop(); 1019 timeout_timer->stop();
1017 emit stopAccounting(); 1020 emit stopAccounting();
1018// p_kppp->con_win->stopClock(); 1021// p_kppp->con_win->stopClock();
1019 return; 1022 return;
1020 } 1023 }
1021 1024
1022 if (prompt->isVisible()) 1025 if (prompt->isVisible())
1023 prompt->hide(); 1026 prompt->hide();
1024 1027
1025 prompt->setConsumed(); 1028 prompt->setConsumed();
1026 messg->setText(i18n("Script timed out!")); 1029 messg->setText(i18n("Script timed out!"));
1027 _ifaceppp->modem()->hangup(); 1030 _ifaceppp->modem()->hangup();
1028 emit stopAccounting(); 1031 emit stopAccounting();
1029// p_kppp->con_win->stopClock(); 1032// p_kppp->con_win->stopClock();
1030 1033
1031 vmain = 0; // let's try again. 1034 vmain = 0; // let's try again.
1032 substate = -1; 1035 substate = -1;
1033} 1036}
1034 1037
1035 1038
1036void ConnectWidget::setScan(const QString &n) { 1039void ConnectWidget::setScan(const QString &n) {
1037 scanning = true; 1040 scanning = true;
1038 scanstr = n; 1041 scanstr = n;
1039 scanbuffer = ""; 1042 scanbuffer = "";
1040 1043
1041 QString ts = i18n("Scanning: %1").arg(n); 1044 QString ts = i18n("Scanning: %1").arg(n);
1042 emit debugMessage(ts); 1045 emit debugMessage(ts);
1043} 1046}
1044 1047
1045 1048
1046void ConnectWidget::setExpect(const QString &n) { 1049void ConnectWidget::setExpect(const QString &n) {
1047 expecting = true; 1050 expecting = true;
1048 expectstr = n; 1051 expectstr = n;
1049 1052
1050 QString ts = i18n("Expecting: %1").arg(n); 1053 QString ts = i18n("Expecting: %1").arg(n);
1051 ts.replace(QRegExp("\n"), "<LF>"); 1054 ts.replace(QRegExp("\n"), "<LF>");
1052 emit debugMessage(ts); 1055 emit debugMessage(ts);
1053 1056
1054 // check if the expected string is in the read buffer already. 1057 // check if the expected string is in the read buffer already.
1055 checkBuffers(); 1058 checkBuffers();
1056} 1059}
1057 1060
1058 1061
1059void ConnectWidget::if_waiting_timed_out() { 1062void ConnectWidget::if_waiting_timed_out() {
1060 if_timer->stop(); 1063 if_timer->stop();
1061 if_timeout_timer->stop(); 1064 if_timeout_timer->stop();
1062 qDebug("if_waiting_timed_out()"); 1065 qDebug("if_waiting_timed_out()");
1063 1066
1064 _ifaceppp->data()->setpppdError(E_IF_TIMEOUT); 1067 _ifaceppp->data()->setpppdError(E_IF_TIMEOUT);
1065 1068
1066 // let's kill the stuck pppd 1069 // let's kill the stuck pppd
1067 _ifaceppp->modem()->killPPPDaemon(); 1070 _ifaceppp->modem()->killPPPDaemon();
1068 1071
1069 emit stopAccounting(); 1072 emit stopAccounting();
1070// p_kppp->con_win->stopClock(); 1073// p_kppp->con_win->stopClock();
1071 1074
1072 1075
1073 // killing ppp will generate a SIGCHLD which will be caught in pppdie() 1076 // killing ppp will generate a SIGCHLD which will be caught in pppdie()
1074 // in main.cpp what happens next will depend on the boolean 1077 // in main.cpp what happens next will depend on the boolean
1075 // reconnect_on_disconnect which is set in ConnectWidget::init(); 1078 // reconnect_on_disconnect which is set in ConnectWidget::init();
1076} 1079}
1077 1080
1078void ConnectWidget::pppdDied() 1081void ConnectWidget::pppdDied()
1079{ 1082{
1080 if_timer->stop(); 1083 if_timer->stop();
1081 if_timeout_timer->stop(); 1084 if_timeout_timer->stop();
1082} 1085}
1083 1086
1084void ConnectWidget::if_waiting_slot() { 1087void ConnectWidget::if_waiting_slot() {
1085 messg->setText(i18n("Logging on to network...")); 1088 messg->setText(i18n("Logging on to network..."));
1086 1089
1087// if(!stats->ifIsUp()) { 1090// if(!stats->ifIsUp()) {
1088 1091
1089// if(_ifaceppp->data()->pppdError() != 0) { 1092// if(_ifaceppp->data()->pppdError() != 0) {
1090// // we are here if pppd died immediately after starting it. 1093// // we are here if pppd died immediately after starting it.
1091// pppdDied(); 1094// pppdDied();
1092// // error message handled in main.cpp: sigPPPDDied() 1095// // error message handled in main.cpp: sigPPPDDied()
1093// return; 1096// return;
1094// } 1097// }
1095 1098
1096// if_timer->start(100, TRUE); // single shot 1099// if_timer->start(100, TRUE); // single shot
1097// return; 1100// return;
1098// } 1101// }
1099 1102
1100 // O.K the ppp interface is up and running 1103 // O.K the ppp interface is up and running
1101 // give it a few time to come up completly (0.2 seconds) 1104 // give it a few time to come up completly (0.2 seconds)
1102 if_timeout_timer->stop(); 1105 if_timeout_timer->stop();
1103 if_timer->stop(); 1106 if_timer->stop();
1104 usleep(200000); 1107 usleep(200000);
1105 1108
1106 if(_ifaceppp->data()->autoDNS()) 1109 if(_ifaceppp->data()->autoDNS())
1107 addpeerdns( _ifaceppp ); 1110 addpeerdns( _ifaceppp );
1108 1111
1109 // Close the debugging window. If we are connected, we 1112 // Close the debugging window. If we are connected, we
1110 // are not really interested in debug output 1113 // are not really interested in debug output
1111 emit closeDebugWindow(); 1114 emit closeDebugWindow();
1112// p_kppp->statdlg->take_stats(); // start taking ppp statistics 1115// p_kppp->statdlg->take_stats(); // start taking ppp statistics
1113 auto_hostname(_ifaceppp); 1116 auto_hostname(_ifaceppp);
1114 1117
1115 if(!_ifaceppp->data()->command_on_connect().isEmpty()) { 1118 if(!_ifaceppp->data()->command_on_connect().isEmpty()) {
1116 messg->setText(i18n("Running startup command...")); 1119 messg->setText(i18n("Running startup command..."));
1117 1120
1118 // make sure that we don't get any async errors 1121 // make sure that we don't get any async errors
1119 qApp->flushX(); 1122 qApp->flushX();
1120 execute_command(_ifaceppp->data()->command_on_connect()); 1123 execute_command(_ifaceppp->data()->command_on_connect());
1121 messg->setText(i18n("Done")); 1124 messg->setText(i18n("Done"));
1122 } 1125 }
1123 1126
1124 // remove the authentication file 1127 // remove the authentication file
1125 _ifaceppp->modem()->removeSecret(AUTH_PAP); 1128 _ifaceppp->modem()->removeSecret(AUTH_PAP);
1126 _ifaceppp->modem()->removeSecret(AUTH_CHAP); 1129 _ifaceppp->modem()->removeSecret(AUTH_CHAP);
1127 1130
1128 emit debugMessage(i18n("Done")); 1131 emit debugMessage(i18n("Done"));
1129 set_con_speed_string(); 1132 set_con_speed_string();
1130 1133
1131// p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed); 1134// p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed);
1132 this->hide(); 1135 this->hide();
1133 messg->setText(""); 1136 messg->setText("");
1134 1137
1138 _ifaceppp->setStatus( true );
1139 // emit _ifaceppp->updateInterface(_ifaceppp);
1140
1135 // prepare the con_win so as to have the right size for 1141 // prepare the con_win so as to have the right size for
1136 // accounting / non-accounting mode 1142 // accounting / non-accounting mode
1137// if(p_kppp->acct != 0) 1143// if(p_kppp->acct != 0)
1138// p_kppp->con_win->accounting(p_kppp->acct->running()); 1144// p_kppp->con_win->accounting(p_kppp->acct->running());
1139// else 1145// else
1140// p_kppp->con_win->accounting(false); 1146// p_kppp->con_win->accounting(false);
1141 1147
1142// if (_ifaceppp->data()->get_dock_into_panel()) { 1148// if (_ifaceppp->data()->get_dock_into_panel()) {
1143// // DockWidget::dock_widget->show(); 1149// // DockWidget::dock_widget->show();
1144// // DockWidget::dock_widget->take_stats(); 1150// // DockWidget::dock_widget->take_stats();
1145// // this->hide(); 1151// // this->hide();
1146// } 1152// }
1147// else { 1153// else {
1148// // p_kppp->con_win->show(); 1154// // p_kppp->con_win->show();
1149 1155
1150// if(_ifaceppp->data()->get_iconify_on_connect()) { 1156// if(_ifaceppp->data()->get_iconify_on_connect()) {
1151// // p_kppp->con_win->showMinimized(); 1157// // p_kppp->con_win->showMinimized();
1152// } 1158// }
1153// } 1159// }
1154 1160
1155 _ifaceppp->modem()->closetty(); 1161 _ifaceppp->modem()->closetty();
1156} 1162}
1157 1163
1158 1164
1159bool ConnectWidget::execppp() { 1165bool ConnectWidget::execppp() {
1160 QString command; 1166 QString command;
1161 1167
1162 command = "pppd"; 1168 command = "pppd";
1163 1169
1164 // as of version 2.3.6 pppd falls back to the real user rights when 1170 // as of version 2.3.6 pppd falls back to the real user rights when
1165 // opening a device given in a command line. To avoid permission conflicts 1171 // opening a device given in a command line. To avoid permission conflicts
1166 // we'll simply leave this argument away. pppd will then use the default tty 1172 // we'll simply leave this argument away. pppd will then use the default tty
1167 // which is the serial port we connected stdin/stdout to in opener.cpp. 1173 // which is the serial port we connected stdin/stdout to in opener.cpp.
1168 // command += " "; 1174 // command += " ";
1169 // command += _ifaceppp->data()->modemDevice(); 1175 // command += _ifaceppp->data()->modemDevice();
1170 1176
1171 command += " " + _ifaceppp->data()->speed(); 1177 command += " " + _ifaceppp->data()->speed();
1172 1178
1173 command += " -detach"; 1179 command += " -detach";
1174 1180
1175 if(_ifaceppp->data()->ipaddr() != "0.0.0.0" || 1181 if(_ifaceppp->data()->ipaddr() != "0.0.0.0" ||
1176 _ifaceppp->data()->gateway() != "0.0.0.0") { 1182 _ifaceppp->data()->gateway() != "0.0.0.0") {
1177 if(_ifaceppp->data()->ipaddr() != "0.0.0.0") { 1183 if(_ifaceppp->data()->ipaddr() != "0.0.0.0") {
1178 command += " "; 1184 command += " ";
1179 command += _ifaceppp->data()->ipaddr(); 1185 command += _ifaceppp->data()->ipaddr();
1180 command += ":"; 1186 command += ":";
1181 } 1187 }
1182 else { 1188 else {
1183 command += " "; 1189 command += " ";
1184 command += ":"; 1190 command += ":";
1185 } 1191 }
1186 1192
1187 if(_ifaceppp->data()->gateway() != "0.0.0.0") 1193 if(_ifaceppp->data()->gateway() != "0.0.0.0")
1188 command += _ifaceppp->data()->gateway(); 1194 command += _ifaceppp->data()->gateway();
1189 } 1195 }
1190 1196
1191 if(_ifaceppp->data()->subnetmask() != "0.0.0.0") 1197 if(_ifaceppp->data()->subnetmask() != "0.0.0.0")
1192 command += " netmask " + _ifaceppp->data()->subnetmask(); 1198 command += " netmask " + _ifaceppp->data()->subnetmask();
1193 1199
1194 if(_ifaceppp->data()->flowcontrol() != "None") { 1200 if(_ifaceppp->data()->flowcontrol() != "None") {
1195 if(_ifaceppp->data()->flowcontrol() == "CRTSCTS") 1201 if(_ifaceppp->data()->flowcontrol() == "CRTSCTS")
1196 command += " crtscts"; 1202 command += " crtscts";
1197 else 1203 else
1198 command += " xonxoff"; 1204 command += " xonxoff";
1199 } 1205 }
1200 1206
1201 if(_ifaceppp->data()->defaultroute()) 1207 if(_ifaceppp->data()->defaultroute())
1202 command += " defaultroute"; 1208 command += " defaultroute";
1203 1209
1204 if(_ifaceppp->data()->autoDNS()) 1210 if(_ifaceppp->data()->autoDNS())
1205 command += " usepeerdns"; 1211 command += " usepeerdns";
1206 1212
1207 QStringList &arglist = _ifaceppp->data()->pppdArgument(); 1213 QStringList &arglist = _ifaceppp->data()->pppdArgument();
1208 for ( QStringList::Iterator it = arglist.begin(); 1214 for ( QStringList::Iterator it = arglist.begin();
1209 it != arglist.end(); 1215 it != arglist.end();
1210 ++it ) 1216 ++it )
1211 { 1217 {
1212 command += " " + *it; 1218 command += " " + *it;
1213 } 1219 }
1214 1220
1215 // PAP settings 1221 // PAP settings
1216 if(_ifaceppp->data()->authMethod() == AUTH_PAP) { 1222 if(_ifaceppp->data()->authMethod() == AUTH_PAP) {
1217 command += " -chap user "; 1223 command += " -chap user ";
1218 command = command + "\"" + _ifaceppp->data()->storedUsername() + "\""; 1224 command = command + "\"" + _ifaceppp->data()->storedUsername() + "\"";
1219 } 1225 }
1220 1226
1221 // CHAP settings 1227 // CHAP settings
1222 if(_ifaceppp->data()->authMethod() == AUTH_CHAP) { 1228 if(_ifaceppp->data()->authMethod() == AUTH_CHAP) {
1223 command += " -pap user "; 1229 command += " -pap user ";
1224 command = command + "\"" + _ifaceppp->data()->storedUsername() + "\""; 1230 command = command + "\"" + _ifaceppp->data()->storedUsername() + "\"";
1225 } 1231 }
1226 1232
1227 // PAP/CHAP settings 1233 // PAP/CHAP settings
1228 if(_ifaceppp->data()->authMethod() == AUTH_PAPCHAP) { 1234 if(_ifaceppp->data()->authMethod() == AUTH_PAPCHAP) {
1229 command += " user "; 1235 command += " user ";
1230 command = command + "\"" + _ifaceppp->data()->storedUsername() + "\""; 1236 command = command + "\"" + _ifaceppp->data()->storedUsername() + "\"";
1231 } 1237 }
1232 1238
1233 // check for debug 1239 // check for debug
1234 if(_ifaceppp->data()->getPPPDebug()) 1240 if(_ifaceppp->data()->getPPPDebug())
1235 command += " debug"; 1241 command += " debug";
1236 1242
1237 if (command.length() > MAX_CMDLEN) { 1243 if (command.length() > MAX_CMDLEN) {
1238 QMessageBox::critical(this, "error", i18n( 1244 QMessageBox::critical(this, "error", i18n(
1239 "pppd command + command-line arguments exceed " 1245 "pppd command + command-line arguments exceed "
1240 "2024 characters in length." 1246 "2024 characters in length."
1241 )); 1247 ));
1242 1248
1243 return false; // nonsensically long command which would bust my buffer buf. 1249 return false; // nonsensically long command which would bust my buffer buf.
1244 } 1250 }
1245 1251
1246 qApp->flushX(); 1252 qApp->flushX();
1247 1253
1248 return _ifaceppp->modem()->execPPPDaemon(command); 1254 return _ifaceppp->modem()->execPPPDaemon(command);
1249} 1255}
1250 1256
1251 1257
1252void ConnectWidget::closeEvent( QCloseEvent *e ) { 1258void ConnectWidget::closeEvent( QCloseEvent *e ) {
1253 e->ignore(); 1259 e->ignore();
1254 emit cancelbutton(); 1260 emit cancelbutton();
1255} 1261}
1256 1262
1257 1263
1258void ConnectWidget::setMsg(const QString &msg) { 1264void ConnectWidget::setMsg(const QString &msg) {
1259 messg->setText(msg); 1265 messg->setText(msg);
1260} 1266}
1261 1267
1262void ConnectWidget::writeline(const QString &s) { 1268void ConnectWidget::writeline(const QString &s) {