author | dwmw2 <dwmw2> | 2003-06-07 17:07:43 (UTC) |
---|---|---|
committer | dwmw2 <dwmw2> | 2003-06-07 17:07:43 (UTC) |
commit | 9ae55ad05f06d1bff20ea0e0fae59781b503a79b (patch) (unidiff) | |
tree | b197565219d69cadecca357a978a9319eeb52220 /noncore | |
parent | b293babbe1e640705163a95e192461d140f590eb (diff) | |
download | opie-9ae55ad05f06d1bff20ea0e0fae59781b503a79b.zip opie-9ae55ad05f06d1bff20ea0e0fae59781b503a79b.tar.gz opie-9ae55ad05f06d1bff20ea0e0fae59781b503a79b.tar.bz2 |
set/use interface status
-rw-r--r-- | noncore/settings/networksettings/ppp/connect.cpp | 6 |
1 files changed, 6 insertions, 0 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 | |||
@@ -68,96 +68,99 @@ | |||
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 | ||
77 | QString old_hostname; | 77 | QString old_hostname; |
78 | bool modified_hostname; | 78 | bool modified_hostname; |
79 | 79 | ||
80 | 80 | ||
81 | ConnectWidget::ConnectWidget(InterfacePPP *ifp, QWidget *parent, const char *name) | 81 | ConnectWidget::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 | if (_ifaceppp->getStatus()) | ||
117 | messg->setText(i18n("Online")); | ||
118 | else | ||
116 | messg->setText(i18n("Offline")); | 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 | } |
@@ -1087,96 +1090,99 @@ void ConnectWidget::if_waiting_slot() { | |||
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 | ||
1159 | bool ConnectWidget::execppp() { | 1165 | bool 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 { |