author | zecke <zecke> | 2004-10-14 01:44:27 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-10-14 01:44:27 (UTC) |
commit | 474150327729d63706b89a54414ead68acd83fc9 (patch) (unidiff) | |
tree | 633f60754361699393e484c4ef774947f46aafa8 | |
parent | a1aed5edd5ccef77d79ccdd2d74f5c029d037617 (diff) | |
download | opie-474150327729d63706b89a54414ead68acd83fc9.zip opie-474150327729d63706b89a54414ead68acd83fc9.tar.gz opie-474150327729d63706b89a54414ead68acd83fc9.tar.bz2 |
-FlowControl and LineTermination are saved and activated by numerical
value now. This makes it work across different translations
-Switch code to use new PPPData::enter() and PPPData::flowcontrol()
-rw-r--r-- | noncore/settings/networksettings/ppp/connect.cpp | 4 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/general.cpp | 34 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/general.h | 4 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/modem.cpp | 16 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/pppdata.cpp | 12 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/pppdata.h | 19 |
6 files changed, 45 insertions, 44 deletions
diff --git a/noncore/settings/networksettings/ppp/connect.cpp b/noncore/settings/networksettings/ppp/connect.cpp index 128877a..8981e01 100644 --- a/noncore/settings/networksettings/ppp/connect.cpp +++ b/noncore/settings/networksettings/ppp/connect.cpp | |||
@@ -1122,194 +1122,194 @@ void ConnectWidget::if_waiting_slot() { | |||
1122 | if(!_ifaceppp->data()->command_on_connect().isEmpty()) { | 1122 | if(!_ifaceppp->data()->command_on_connect().isEmpty()) { |
1123 | messg->setText(QObject::tr("Running startup command...")); | 1123 | messg->setText(QObject::tr("Running startup command...")); |
1124 | 1124 | ||
1125 | // make sure that we don't get any async errors | 1125 | // make sure that we don't get any async errors |
1126 | qApp->flushX(); | 1126 | qApp->flushX(); |
1127 | execute_command(_ifaceppp->data()->command_on_connect()); | 1127 | execute_command(_ifaceppp->data()->command_on_connect()); |
1128 | messg->setText(QObject::tr("Done")); | 1128 | messg->setText(QObject::tr("Done")); |
1129 | } | 1129 | } |
1130 | 1130 | ||
1131 | // remove the authentication file | 1131 | // remove the authentication file |
1132 | _ifaceppp->modem()->removeSecret(AUTH_PAP); | 1132 | _ifaceppp->modem()->removeSecret(AUTH_PAP); |
1133 | _ifaceppp->modem()->removeSecret(AUTH_CHAP); | 1133 | _ifaceppp->modem()->removeSecret(AUTH_CHAP); |
1134 | 1134 | ||
1135 | emit debugMessage(QObject::tr("Done")); | 1135 | emit debugMessage(QObject::tr("Done")); |
1136 | set_con_speed_string(); | 1136 | set_con_speed_string(); |
1137 | 1137 | ||
1138 | // p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed); | 1138 | // p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed); |
1139 | // this->hide(); | 1139 | // this->hide(); |
1140 | // messg->setText(""); | 1140 | // messg->setText(""); |
1141 | 1141 | ||
1142 | _ifaceppp->setStatus( true ); | 1142 | _ifaceppp->setStatus( true ); |
1143 | 1143 | ||
1144 | m_refreshTimer = new QTimer( this ); | 1144 | m_refreshTimer = new QTimer( this ); |
1145 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | 1145 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); |
1146 | m_refreshTimer->start( 3000 ); | 1146 | m_refreshTimer->start( 3000 ); |
1147 | //_ifaceppp->refresh(); | 1147 | //_ifaceppp->refresh(); |
1148 | // emit _ifaceppp->updateInterface(_ifaceppp); | 1148 | // emit _ifaceppp->updateInterface(_ifaceppp); |
1149 | 1149 | ||
1150 | // 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 |
1151 | // accounting / non-accounting mode | 1151 | // accounting / non-accounting mode |
1152 | // if(p_kppp->acct != 0) | 1152 | // if(p_kppp->acct != 0) |
1153 | // p_kppp->con_win->accounting(p_kppp->acct->running()); | 1153 | // p_kppp->con_win->accounting(p_kppp->acct->running()); |
1154 | // else | 1154 | // else |
1155 | // p_kppp->con_win->accounting(false); | 1155 | // p_kppp->con_win->accounting(false); |
1156 | 1156 | ||
1157 | // if (_ifaceppp->data()->get_dock_into_panel()) { | 1157 | // if (_ifaceppp->data()->get_dock_into_panel()) { |
1158 | // // DockWidget::dock_widget->show(); | 1158 | // // DockWidget::dock_widget->show(); |
1159 | // // DockWidget::dock_widget->take_stats(); | 1159 | // // DockWidget::dock_widget->take_stats(); |
1160 | // // this->hide(); | 1160 | // // this->hide(); |
1161 | // } | 1161 | // } |
1162 | // else { | 1162 | // else { |
1163 | // // p_kppp->con_win->show(); | 1163 | // // p_kppp->con_win->show(); |
1164 | 1164 | ||
1165 | // if(_ifaceppp->data()->get_iconify_on_connect()) { | 1165 | // if(_ifaceppp->data()->get_iconify_on_connect()) { |
1166 | // // p_kppp->con_win->showMinimized(); | 1166 | // // p_kppp->con_win->showMinimized(); |
1167 | // } | 1167 | // } |
1168 | // } | 1168 | // } |
1169 | 1169 | ||
1170 | _ifaceppp->modem()->closetty(); | 1170 | _ifaceppp->modem()->closetty(); |
1171 | } | 1171 | } |
1172 | 1172 | ||
1173 | void ConnectWidget::refresh() { | 1173 | void ConnectWidget::refresh() { |
1174 | _ifaceppp->refresh(); | 1174 | _ifaceppp->refresh(); |
1175 | if ( _ifaceppp->getStatus() ) { | 1175 | if ( _ifaceppp->getStatus() ) { |
1176 | messg->setText(QObject::tr("Online")); | 1176 | messg->setText(QObject::tr("Online")); |
1177 | } else { | 1177 | } else { |
1178 | messg->setText(QObject::tr("Offline")); | 1178 | messg->setText(QObject::tr("Offline")); |
1179 | } | 1179 | } |
1180 | } | 1180 | } |
1181 | 1181 | ||
1182 | 1182 | ||
1183 | bool ConnectWidget::execppp() { | 1183 | bool ConnectWidget::execppp() { |
1184 | QString command; | 1184 | QString command; |
1185 | 1185 | ||
1186 | command = "pppd"; | 1186 | command = "pppd"; |
1187 | 1187 | ||
1188 | // 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 |
1189 | // 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 |
1190 | // 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 |
1191 | // 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. |
1192 | // command += " "; | 1192 | // command += " "; |
1193 | // command += _ifaceppp->data()->modemDevice(); | 1193 | // command += _ifaceppp->data()->modemDevice(); |
1194 | 1194 | ||
1195 | command += " " + _ifaceppp->data()->speed(); | 1195 | command += " " + _ifaceppp->data()->speed(); |
1196 | 1196 | ||
1197 | command += " -detach"; | 1197 | command += " -detach"; |
1198 | 1198 | ||
1199 | if(_ifaceppp->data()->ipaddr() != "0.0.0.0" || | 1199 | if(_ifaceppp->data()->ipaddr() != "0.0.0.0" || |
1200 | _ifaceppp->data()->gateway() != "0.0.0.0") { | 1200 | _ifaceppp->data()->gateway() != "0.0.0.0") { |
1201 | if(_ifaceppp->data()->ipaddr() != "0.0.0.0") { | 1201 | if(_ifaceppp->data()->ipaddr() != "0.0.0.0") { |
1202 | command += " "; | 1202 | command += " "; |
1203 | command += _ifaceppp->data()->ipaddr(); | 1203 | command += _ifaceppp->data()->ipaddr(); |
1204 | command += ":"; | 1204 | command += ":"; |
1205 | } | 1205 | } |
1206 | else { | 1206 | else { |
1207 | command += " "; | 1207 | command += " "; |
1208 | command += ":"; | 1208 | command += ":"; |
1209 | } | 1209 | } |
1210 | 1210 | ||
1211 | if(_ifaceppp->data()->gateway() != "0.0.0.0") | 1211 | if(_ifaceppp->data()->gateway() != "0.0.0.0") |
1212 | command += _ifaceppp->data()->gateway(); | 1212 | command += _ifaceppp->data()->gateway(); |
1213 | } | 1213 | } |
1214 | 1214 | ||
1215 | if(_ifaceppp->data()->subnetmask() != "0.0.0.0") | 1215 | if(_ifaceppp->data()->subnetmask() != "0.0.0.0") |
1216 | command += " netmask " + _ifaceppp->data()->subnetmask(); | 1216 | command += " netmask " + _ifaceppp->data()->subnetmask(); |
1217 | 1217 | ||
1218 | if(_ifaceppp->data()->flowcontrol() != "None") { | 1218 | if(_ifaceppp->data()->flowcontrol() != PPPData::FlowNone) { |
1219 | if(_ifaceppp->data()->flowcontrol() == "CRTSCTS") | 1219 | if(_ifaceppp->data()->flowcontrol() == PPPData::FlowHardware) |
1220 | command += " crtscts"; | 1220 | command += " crtscts"; |
1221 | else | 1221 | else |
1222 | command += " xonxoff"; | 1222 | command += " xonxoff"; |
1223 | } | 1223 | } |
1224 | 1224 | ||
1225 | if(_ifaceppp->data()->defaultroute()) | 1225 | if(_ifaceppp->data()->defaultroute()) |
1226 | command += " defaultroute"; | 1226 | command += " defaultroute"; |
1227 | 1227 | ||
1228 | if(_ifaceppp->data()->autoDNS()) | 1228 | if(_ifaceppp->data()->autoDNS()) |
1229 | command += " usepeerdns"; | 1229 | command += " usepeerdns"; |
1230 | 1230 | ||
1231 | 1231 | ||
1232 | // PAP settings | 1232 | // PAP settings |
1233 | if(_ifaceppp->data()->authMethod() == AUTH_PAP) { | 1233 | if(_ifaceppp->data()->authMethod() == AUTH_PAP) { |
1234 | command += " -chap user "; | 1234 | command += " -chap user "; |
1235 | command = command + _ifaceppp->data()->storedUsername(); | 1235 | command = command + _ifaceppp->data()->storedUsername(); |
1236 | } | 1236 | } |
1237 | 1237 | ||
1238 | // CHAP settings | 1238 | // CHAP settings |
1239 | if(_ifaceppp->data()->authMethod() == AUTH_CHAP) { | 1239 | if(_ifaceppp->data()->authMethod() == AUTH_CHAP) { |
1240 | command += " -pap user "; | 1240 | command += " -pap user "; |
1241 | command = command + _ifaceppp->data()->storedUsername(); | 1241 | command = command + _ifaceppp->data()->storedUsername(); |
1242 | } | 1242 | } |
1243 | 1243 | ||
1244 | // PAP/CHAP settings | 1244 | // PAP/CHAP settings |
1245 | if(_ifaceppp->data()->authMethod() == AUTH_PAPCHAP) { | 1245 | if(_ifaceppp->data()->authMethod() == AUTH_PAPCHAP) { |
1246 | QString tmpName = _ifaceppp->data()->storedUsername(); | 1246 | QString tmpName = _ifaceppp->data()->storedUsername(); |
1247 | if ( !tmpName.isEmpty() ) { | 1247 | if ( !tmpName.isEmpty() ) { |
1248 | command += " user "; | 1248 | command += " user "; |
1249 | command = command + tmpName; | 1249 | command = command + tmpName; |
1250 | } | 1250 | } |
1251 | } | 1251 | } |
1252 | 1252 | ||
1253 | // check for debug | 1253 | // check for debug |
1254 | if(_ifaceppp->data()->getPPPDebug()) | 1254 | if(_ifaceppp->data()->getPPPDebug()) |
1255 | command += " debug"; | 1255 | command += " debug"; |
1256 | 1256 | ||
1257 | QStringList &arglist = _ifaceppp->data()->pppdArgument(); | 1257 | QStringList &arglist = _ifaceppp->data()->pppdArgument(); |
1258 | for ( QStringList::Iterator it = arglist.begin(); | 1258 | for ( QStringList::Iterator it = arglist.begin(); |
1259 | it != arglist.end(); | 1259 | it != arglist.end(); |
1260 | ++it ) | 1260 | ++it ) |
1261 | { | 1261 | { |
1262 | command += " " + *it; | 1262 | command += " " + *it; |
1263 | } | 1263 | } |
1264 | 1264 | ||
1265 | command += " call opie-kppp logfd 11"; | 1265 | command += " call opie-kppp logfd 11"; |
1266 | 1266 | ||
1267 | if (command.length() > MAX_CMDLEN) { | 1267 | if (command.length() > MAX_CMDLEN) { |
1268 | QMessageBox::critical(this, "error", QObject::tr( | 1268 | QMessageBox::critical(this, "error", QObject::tr( |
1269 | "pppd command + command-line arguments exceed " | 1269 | "pppd command + command-line arguments exceed " |
1270 | "2024 characters in length." | 1270 | "2024 characters in length." |
1271 | )); | 1271 | )); |
1272 | 1272 | ||
1273 | return false; // nonsensically long command which would bust my buffer buf. | 1273 | return false; // nonsensically long command which would bust my buffer buf. |
1274 | } | 1274 | } |
1275 | 1275 | ||
1276 | owarn << "Command IS: " << command.latin1() << "" << oendl; | 1276 | owarn << "Command IS: " << command.latin1() << "" << oendl; |
1277 | 1277 | ||
1278 | qApp->flushX(); | 1278 | qApp->flushX(); |
1279 | 1279 | ||
1280 | return _ifaceppp->modem()->execPPPDaemon(command); | 1280 | return _ifaceppp->modem()->execPPPDaemon(command); |
1281 | } | 1281 | } |
1282 | 1282 | ||
1283 | 1283 | ||
1284 | void ConnectWidget::closeEvent( QCloseEvent *e ) { | 1284 | void ConnectWidget::closeEvent( QCloseEvent *e ) { |
1285 | e->ignore(); | 1285 | e->ignore(); |
1286 | emit cancelbutton(); | 1286 | emit cancelbutton(); |
1287 | } | 1287 | } |
1288 | 1288 | ||
1289 | 1289 | ||
1290 | void ConnectWidget::setMsg(const QString &msg) { | 1290 | void ConnectWidget::setMsg(const QString &msg) { |
1291 | messg->setText(msg); | 1291 | messg->setText(msg); |
1292 | } | 1292 | } |
1293 | 1293 | ||
1294 | void ConnectWidget::writeline(const QString &s) { | 1294 | void ConnectWidget::writeline(const QString &s) { |
1295 | _ifaceppp->modem()->writeLine(s.local8Bit()); | 1295 | _ifaceppp->modem()->writeLine(s.local8Bit()); |
1296 | } | 1296 | } |
1297 | 1297 | ||
1298 | // Set the hostname and domain from DNS Server | 1298 | // Set the hostname and domain from DNS Server |
1299 | void auto_hostname(InterfacePPP *_ifaceppp) { | 1299 | void auto_hostname(InterfacePPP *_ifaceppp) { |
1300 | struct in_addr local_ip; | 1300 | struct in_addr local_ip; |
1301 | struct hostent *hostname_entry; | 1301 | struct hostent *hostname_entry; |
1302 | QString new_hostname; | 1302 | QString new_hostname; |
1303 | int dot; | 1303 | int dot; |
1304 | char tmp_str[100]; // buffer overflow safe | 1304 | char tmp_str[100]; // buffer overflow safe |
1305 | 1305 | ||
1306 | gethostname(tmp_str, sizeof(tmp_str)); | 1306 | gethostname(tmp_str, sizeof(tmp_str)); |
1307 | tmp_str[sizeof(tmp_str)-1]=0; // panic | 1307 | tmp_str[sizeof(tmp_str)-1]=0; // panic |
1308 | old_hostname=tmp_str; // copy to QString | 1308 | old_hostname=tmp_str; // copy to QString |
1309 | 1309 | ||
1310 | // if (!p_kppp->stats->local_ip_address.isEmpty() && _ifaceppp->data()->autoname()) { | 1310 | // if (!p_kppp->stats->local_ip_address.isEmpty() && _ifaceppp->data()->autoname()) { |
1311 | if ( _ifaceppp->data()->autoname()) { | 1311 | if ( _ifaceppp->data()->autoname()) { |
1312 | // 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()); |
1313 | 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); |
1314 | 1314 | ||
1315 | if (hostname_entry != 0L) { | 1315 | if (hostname_entry != 0L) { |
diff --git a/noncore/settings/networksettings/ppp/general.cpp b/noncore/settings/networksettings/ppp/general.cpp index 5e2a04f..9457173 100644 --- a/noncore/settings/networksettings/ppp/general.cpp +++ b/noncore/settings/networksettings/ppp/general.cpp | |||
@@ -99,369 +99,355 @@ ModemWidget::ModemWidget( PPPData *pd, QWidget *parent, const char *name ) | |||
99 | 99 | ||
100 | QWhatsThis::add(label1,tmp); | 100 | QWhatsThis::add(label1,tmp); |
101 | QWhatsThis::add(modemdevice,tmp); | 101 | QWhatsThis::add(modemdevice,tmp); |
102 | 102 | ||
103 | 103 | ||
104 | label1 = new QLabel(tr("&Flow control:"), this); | 104 | label1 = new QLabel(tr("&Flow control:"), this); |
105 | tl->addWidget(label1, 2, 0); | 105 | tl->addWidget(label1, 2, 0); |
106 | 106 | ||
107 | flowcontrol = new QComboBox(false, this); | 107 | flowcontrol = new QComboBox(false, this); |
108 | label1->setBuddy(flowcontrol); | 108 | label1->setBuddy(flowcontrol); |
109 | flowcontrol->insertItem(tr("Hardware [CRTSCTS]")); | 109 | flowcontrol->insertItem(tr("Hardware [CRTSCTS]")); |
110 | flowcontrol->insertItem(tr("Software [XON/XOFF]")); | 110 | flowcontrol->insertItem(tr("Software [XON/XOFF]")); |
111 | flowcontrol->insertItem(tr("None")); | 111 | flowcontrol->insertItem(tr("None")); |
112 | tl->addWidget(flowcontrol, 2, 1); | 112 | tl->addWidget(flowcontrol, 2, 1); |
113 | // connect(flowcontrol, SIGNAL(activated(int)), | 113 | // connect(flowcontrol, SIGNAL(activated(int)), |
114 | // SLOT(setflowcontrol(int))); | 114 | // SLOT(setflowcontrol(int))); |
115 | 115 | ||
116 | tmp = tr("<p>Specifies how the serial port and modem\n" | 116 | tmp = tr("<p>Specifies how the serial port and modem\n" |
117 | "communicate. You should not change this unless\n" | 117 | "communicate. You should not change this unless\n" |
118 | "you know what you are doing.\n" | 118 | "you know what you are doing.\n" |
119 | "\n" | 119 | "\n" |
120 | "<b>Default</b>: CRTSCTS"); | 120 | "<b>Default</b>: CRTSCTS"); |
121 | 121 | ||
122 | QWhatsThis::add(label1,tmp); | 122 | QWhatsThis::add(label1,tmp); |
123 | QWhatsThis::add(flowcontrol,tmp); | 123 | QWhatsThis::add(flowcontrol,tmp); |
124 | 124 | ||
125 | QLabel *labelenter = new QLabel(tr("&Line termination:"), this); | 125 | QLabel *labelenter = new QLabel(tr("&Line termination:"), this); |
126 | tl->addWidget(labelenter, 3, 0); | 126 | tl->addWidget(labelenter, 3, 0); |
127 | 127 | ||
128 | enter = new QComboBox(false, this); | 128 | enter = new QComboBox(false, this); |
129 | labelenter->setBuddy(enter); | 129 | labelenter->setBuddy(enter); |
130 | enter->insertItem("CR"); | 130 | enter->insertItem("CR"); |
131 | enter->insertItem("LF"); | 131 | enter->insertItem("LF"); |
132 | enter->insertItem("CR/LF"); | 132 | enter->insertItem("CR/LF"); |
133 | tl->addWidget(enter, 3, 1); | 133 | tl->addWidget(enter, 3, 1); |
134 | // connect(enter, SIGNAL(activated(int)), SLOT(setenter(int))); | 134 | // connect(enter, SIGNAL(activated(int)), SLOT(setenter(int))); |
135 | tmp = tr("<p>Specifies how AT commands are sent to your\n" | 135 | tmp = tr("<p>Specifies how AT commands are sent to your\n" |
136 | "modem. Most modems will work fine with the\n" | 136 | "modem. Most modems will work fine with the\n" |
137 | "default <i>CR/LF</i>. If your modem does not react\n" | 137 | "default <i>CR/LF</i>. If your modem does not react\n" |
138 | "to the init string, you should try different\n" | 138 | "to the init string, you should try different\n" |
139 | "settings here\n" | 139 | "settings here\n" |
140 | "\n" | 140 | "\n" |
141 | "<b>Default</b>: CR/LF"); | 141 | "<b>Default</b>: CR/LF"); |
142 | 142 | ||
143 | QWhatsThis::add(labelenter,tmp); | 143 | QWhatsThis::add(labelenter,tmp); |
144 | QWhatsThis::add(enter, tmp); | 144 | QWhatsThis::add(enter, tmp); |
145 | 145 | ||
146 | QLabel *baud_label = new QLabel(tr("Co&nnection speed:"), this); | 146 | QLabel *baud_label = new QLabel(tr("Co&nnection speed:"), this); |
147 | tl->addWidget(baud_label, 4, 0); | 147 | tl->addWidget(baud_label, 4, 0); |
148 | baud_c = new QComboBox(this); | 148 | baud_c = new QComboBox(this); |
149 | baud_label->setBuddy(baud_c); | 149 | baud_label->setBuddy(baud_c); |
150 | 150 | ||
151 | static const char *baudrates[] = | 151 | static const char *baudrates[] = |
152 | { | 152 | { |
153 | 153 | ||
154 | #ifdef B460800 | 154 | #ifdef B460800 |
155 | "460800", | 155 | "460800", |
156 | #endif | 156 | #endif |
157 | 157 | ||
158 | #ifdef B230400 | 158 | #ifdef B230400 |
159 | "230400", | 159 | "230400", |
160 | #endif | 160 | #endif |
161 | 161 | ||
162 | #ifdef B115200 | 162 | #ifdef B115200 |
163 | "115200", | 163 | "115200", |
164 | #endif | 164 | #endif |
165 | 165 | ||
166 | #ifdef B57600 | 166 | #ifdef B57600 |
167 | "57600", | 167 | "57600", |
168 | #endif | 168 | #endif |
169 | 169 | ||
170 | "38400", | 170 | "38400", |
171 | "19200", | 171 | "19200", |
172 | "9600", | 172 | "9600", |
173 | "2400", | 173 | "2400", |
174 | 0 | 174 | 0 |
175 | }; | 175 | }; |
176 | 176 | ||
177 | for(k = 0; baudrates[k]; k++) | 177 | for(k = 0; baudrates[k]; k++) |
178 | baud_c->insertItem(baudrates[k]); | 178 | baud_c->insertItem(baudrates[k]); |
179 | 179 | ||
180 | baud_c->setCurrentItem(3); | 180 | baud_c->setCurrentItem(3); |
181 | // connect(baud_c, SIGNAL(activated(int)), | 181 | // connect(baud_c, SIGNAL(activated(int)), |
182 | // this, SLOT(speed_selection(int))); | 182 | // this, SLOT(speed_selection(int))); |
183 | tl->addWidget(baud_c, 4, 1); | 183 | tl->addWidget(baud_c, 4, 1); |
184 | 184 | ||
185 | tmp = tr("Specifies the speed your modem and the serial\n" | 185 | tmp = tr("Specifies the speed your modem and the serial\n" |
186 | "port talk to each other. You should begin with\n" | 186 | "port talk to each other. You should begin with\n" |
187 | "the default of 38400 bits/sec. If everything\n" | 187 | "the default of 38400 bits/sec. If everything\n" |
188 | "works you can try to increase this value, but to\n" | 188 | "works you can try to increase this value, but to\n" |
189 | "no more than 115200 bits/sec (unless you know\n" | 189 | "no more than 115200 bits/sec (unless you know\n" |
190 | "that your serial port supports higher speeds)."); | 190 | "that your serial port supports higher speeds)."); |
191 | 191 | ||
192 | QWhatsThis::add(baud_label,tmp); | 192 | QWhatsThis::add(baud_label,tmp); |
193 | QWhatsThis::add(baud_c,tmp); | 193 | QWhatsThis::add(baud_c,tmp); |
194 | 194 | ||
195 | for(int i=0; i <= enter->count()-1; i++) | ||
196 | { | ||
197 | if(_pppdata->enter() == enter->text(i)) | ||
198 | enter->setCurrentItem(i); | ||
199 | } | ||
200 | |||
201 | tl->addRowSpacing(5, 10); | 195 | tl->addRowSpacing(5, 10); |
202 | 196 | ||
203 | //Modem Lock File | 197 | //Modem Lock File |
204 | modemlockfile = new QCheckBox(tr("&Use lock file"), this); | 198 | modemlockfile = new QCheckBox(tr("&Use lock file"), this); |
205 | |||
206 | modemlockfile->setChecked(_pppdata->modemLockFile()); | 199 | modemlockfile->setChecked(_pppdata->modemLockFile()); |
207 | // connect(modemlockfile, SIGNAL(toggled(bool)), | 200 | // connect(modemlockfile, SIGNAL(toggled(bool)), |
208 | // SLOT(modemlockfilechanged(bool))); | 201 | // SLOT(modemlockfilechanged(bool))); |
209 | tl->addMultiCellWidget(modemlockfile, 6, 6, 0, 1); | 202 | tl->addMultiCellWidget(modemlockfile, 6, 6, 0, 1); |
210 | // l12->addStretch(1); | 203 | // l12->addStretch(1); |
211 | QWhatsThis::add(modemlockfile, | 204 | QWhatsThis::add(modemlockfile, |
212 | tr("<p>To prevent other programs from accessing the\n" | 205 | tr("<p>To prevent other programs from accessing the\n" |
213 | "modem while a connection is established, a\n" | 206 | "modem while a connection is established, a\n" |
214 | "file can be created to indicate that the modem\n" | 207 | "file can be created to indicate that the modem\n" |
215 | "is in use. On Linux an example file would be\n" | 208 | "is in use. On Linux an example file would be\n" |
216 | "<tt>/var/lock/LCK..ttyS1</tt>\n" | 209 | "<tt>/var/lock/LCK..ttyS1</tt>\n" |
217 | "Here you can select whether this locking will\n" | 210 | "Here you can select whether this locking will\n" |
218 | "be done.\n" | 211 | "be done.\n" |
219 | "\n" | 212 | "\n" |
220 | "<b>Default</b>: On")); | 213 | "<b>Default</b>: On")); |
221 | 214 | ||
222 | // Modem Timeout Line Edit Box | 215 | // Modem Timeout Line Edit Box |
223 | QHBoxLayout *timeoutLayout = new QHBoxLayout( this ); | 216 | QHBoxLayout *timeoutLayout = new QHBoxLayout( this ); |
224 | QLabel *timeoutlabel = new QLabel( tr("Modem timeout:") ,this, "timeout" ); | 217 | QLabel *timeoutlabel = new QLabel( tr("Modem timeout:") ,this, "timeout" ); |
225 | modemtimeout = new QSpinBox( 1, 120, 1, this, "modemTimeout" ); | 218 | modemtimeout = new QSpinBox( 1, 120, 1, this, "modemTimeout" ); |
226 | // modemtimeout = new KIntNumInput(_pppdata->modemTimeout(), this); | 219 | // modemtimeout = new KIntNumInput(_pppdata->modemTimeout(), this); |
227 | // modemtimeout->setLabel(tr("Modem &timeout:")); | 220 | // modemtimeout->setLabel(tr("Modem &timeout:")); |
228 | // modemtimeout->setRange(1, 120, 1); | 221 | // modemtimeout->setRange(1, 120, 1); |
229 | modemtimeout->setSuffix(tr(" sec")); | 222 | modemtimeout->setSuffix(tr(" sec")); |
230 | modemtimeout->setValue( _pppdata->modemTimeout() ); | 223 | modemtimeout->setValue( _pppdata->modemTimeout() ); |
231 | // connect(modemtimeout, SIGNAL(valueChanged(int)), | 224 | // connect(modemtimeout, SIGNAL(valueChanged(int)), |
232 | // SLOT(modemtimeoutchanged(int))); | 225 | // SLOT(modemtimeoutchanged(int))); |
233 | timeoutLayout->addWidget(timeoutlabel); | 226 | timeoutLayout->addWidget(timeoutlabel); |
234 | timeoutLayout->addWidget(modemtimeout); | 227 | timeoutLayout->addWidget(modemtimeout); |
235 | tl->addMultiCellLayout(timeoutLayout, 7, 7, 0, 1); | 228 | tl->addMultiCellLayout(timeoutLayout, 7, 7, 0, 1); |
236 | 229 | ||
237 | QWhatsThis::add(modemtimeout, | 230 | QWhatsThis::add(modemtimeout, |
238 | tr("This specifies how long <i>kppp</i> waits for a\n" | 231 | tr("This specifies how long <i>kppp</i> waits for a\n" |
239 | "<i>CONNECT</i> response from your modem. The\n" | 232 | "<i>CONNECT</i> response from your modem. The\n" |
240 | "recommended value is 30 seconds.")); | 233 | "recommended value is 30 seconds.")); |
241 | 234 | ||
242 | //set stuff from gpppdata | 235 | //set stuff from gpppdata |
243 | for(int i=0; i <= enter->count()-1; i++) | 236 | enter->setCurrentItem( static_cast<int>(_pppdata->enter()) ); |
244 | { | 237 | flowcontrol->setCurrentItem( static_cast<int>( _pppdata->flowcontrol() ) ); |
245 | if(_pppdata->enter() == enter->text(i)) | ||
246 | enter->setCurrentItem(i); | ||
247 | } | ||
248 | 238 | ||
249 | for(int i=0; i <= modemdevice->count()-1; i++) | 239 | for(int i=0; i <= modemdevice->count()-1; i++) |
250 | { | 240 | { |
251 | if(_pppdata->modemDevice() == modemdevice->text(i)) | 241 | if(_pppdata->modemDevice() == modemdevice->text(i)) |
252 | modemdevice->setCurrentItem(i); | 242 | modemdevice->setCurrentItem(i); |
253 | } | 243 | } |
254 | 244 | ||
255 | for(int i=0; i <= flowcontrol->count()-1; i++) | ||
256 | { | ||
257 | if(_pppdata->flowcontrol() == flowcontrol->text(i)) | ||
258 | flowcontrol->setCurrentItem(i); | ||
259 | } | ||
260 | |||
261 | //set the modem speed | 245 | //set the modem speed |
262 | for(int i=0; i < baud_c->count(); i++) | 246 | for(int i=0; i < baud_c->count(); i++) |
263 | if(baud_c->text(i) == _pppdata->speed()) | 247 | if(baud_c->text(i) == _pppdata->speed()) |
264 | baud_c->setCurrentItem(i); | 248 | baud_c->setCurrentItem(i); |
265 | 249 | ||
266 | tl->setRowStretch(1, 1); | 250 | tl->setRowStretch(1, 1); |
267 | } | 251 | } |
268 | 252 | ||
269 | ModemWidget::~ModemWidget() | 253 | ModemWidget::~ModemWidget() |
270 | { | 254 | { |
271 | QStringList devs; | 255 | QStringList devs; |
272 | 256 | ||
273 | for (int i=0;i<modemdevice->count();i++) | 257 | for (int i=0;i<modemdevice->count();i++) |
274 | { | 258 | { |
275 | QString s = modemdevice->text(i); | 259 | QString s = modemdevice->text(i); |
276 | s.simplifyWhiteSpace(); | 260 | s.simplifyWhiteSpace(); |
277 | if (! s.isEmpty() ) devs << s; | 261 | if (! s.isEmpty() ) devs << s; |
278 | } | 262 | } |
279 | 263 | ||
280 | 264 | ||
281 | QString edited = modemdevice->currentText(); | 265 | QString edited = modemdevice->currentText(); |
282 | if ( !( edited ).isEmpty() ) | 266 | if ( !( edited ).isEmpty() ) |
283 | { | 267 | { |
284 | edited.simplifyWhiteSpace(); | 268 | edited.simplifyWhiteSpace(); |
285 | if ( devs.contains( edited ) == 0 ) | 269 | if ( devs.contains( edited ) == 0 ) |
286 | { | 270 | { |
287 | devs << edited; | 271 | devs << edited; |
288 | } | 272 | } |
289 | } | 273 | } |
290 | 274 | ||
291 | 275 | ||
292 | Config cfg("NetworkSetupPPP"); | 276 | Config cfg("NetworkSetupPPP"); |
293 | cfg.setGroup("Devices_General"); | 277 | cfg.setGroup("Devices_General"); |
294 | cfg.writeEntry("devices",devs,','); | 278 | cfg.writeEntry("devices",devs,','); |
295 | 279 | ||
296 | } | 280 | } |
297 | 281 | ||
298 | // void ModemWidget::speed_selection(int) { | 282 | // void ModemWidget::speed_selection(int) { |
299 | // _pppdata->setSpeed(baud_c->text(baud_c->currentItem())); | 283 | // _pppdata->setSpeed(baud_c->text(baud_c->currentItem())); |
300 | // } | 284 | // } |
301 | 285 | ||
302 | 286 | ||
303 | // void ModemWidget::setenter(int ) { | 287 | // void ModemWidget::setenter(int ) { |
304 | // _pppdata->setEnter(enter->text(enter->currentItem())); | 288 | // _pppdata->setEnter(enter->text(enter->currentItem())); |
305 | // } | 289 | // } |
306 | 290 | ||
307 | 291 | ||
308 | // void ModemWidget::setmodemdc(int i) { | 292 | // void ModemWidget::setmodemdc(int i) { |
309 | // _pppdata->setModemDevice(modemdevice->text(i)); | 293 | // _pppdata->setModemDevice(modemdevice->text(i)); |
310 | // } | 294 | // } |
311 | 295 | ||
312 | // void ModemWidget::setmodemdc( const QString &string ) { | 296 | // void ModemWidget::setmodemdc( const QString &string ) { |
313 | // _pppdata->setModemDevice( string ); | 297 | // _pppdata->setModemDevice( string ); |
314 | // } | 298 | // } |
315 | 299 | ||
316 | // void ModemWidget::setflowcontrol(int i) { | 300 | // void ModemWidget::setflowcontrol(int i) { |
317 | // _pppdata->setFlowcontrol(flowcontrol->text(i)); | 301 | // _pppdata->setFlowcontrol(flowcontrol->text(i)); |
318 | // } | 302 | // } |
319 | 303 | ||
320 | 304 | ||
321 | // void ModemWidget::modemlockfilechanged(bool set) { | 305 | // void ModemWidget::modemlockfilechanged(bool set) { |
322 | // _pppdata->setModemLockFile(set); | 306 | // _pppdata->setModemLockFile(set); |
323 | // } | 307 | // } |
324 | 308 | ||
325 | 309 | ||
326 | // void ModemWidget::modemtimeoutchanged(int n) { | 310 | // void ModemWidget::modemtimeoutchanged(int n) { |
327 | // _pppdata->setModemTimeout(n); | 311 | // _pppdata->setModemTimeout(n); |
328 | // } | 312 | // } |
329 | 313 | ||
330 | 314 | ||
331 | 315 | ||
332 | bool ModemWidget::save() | 316 | bool ModemWidget::save() |
333 | { | 317 | { |
334 | //first check to make sure that the device name is unique! | 318 | //first check to make sure that the device name is unique! |
335 | if(modemname->text().isEmpty() || | 319 | if(modemname->text().isEmpty() || |
336 | !_pppdata->isUniqueDevname(modemname->text())) | 320 | !_pppdata->isUniqueDevname(modemname->text())) |
337 | return false; | 321 | return false; |
338 | 322 | ||
339 | _pppdata->setDevname( modemname->text() ); | 323 | _pppdata->setDevname( modemname->text() ); |
340 | _pppdata->setModemDevice( modemdevice->currentText() ); | 324 | _pppdata->setModemDevice( modemdevice->currentText() ); |
341 | _pppdata->setFlowcontrol(flowcontrol->currentText()); | 325 | _pppdata->setFlowcontrol(static_cast<PPPData::FlowControl>(flowcontrol->currentItem())); |
342 | _pppdata->setFlowcontrol(flowcontrol->currentText()); | 326 | _pppdata->setEnter( static_cast<PPPData::LineTermination>(enter->currentItem())); |
343 | _pppdata->setSpeed(baud_c->currentText()); | 327 | _pppdata->setSpeed(baud_c->currentText()); |
344 | _pppdata->setModemLockFile( modemlockfile->isChecked()); | 328 | _pppdata->setModemLockFile( modemlockfile->isChecked()); |
345 | _pppdata->setModemTimeout( modemtimeout->value() ); | 329 | _pppdata->setModemTimeout( modemtimeout->value() ); |
346 | return true; | 330 | return true; |
347 | 331 | ||
348 | } | 332 | } |
349 | 333 | ||
350 | void ModemWidget::slotBeforeModemQuery() | 334 | void ModemWidget::slotBeforeModemQuery() |
351 | { | 335 | { |
352 | m_oldModemDev = _pppdata->modemDevice(); | 336 | m_oldModemDev = _pppdata->modemDevice(); |
353 | m_oldFlowControl = _pppdata->flowcontrol(); | 337 | m_oldFlowControl = static_cast<int>( _pppdata->flowcontrol() ); |
354 | m_oldSpeed = _pppdata->speed(); | 338 | m_oldSpeed = _pppdata->speed(); |
355 | m_oldModemLock = _pppdata->modemLockFile(); | 339 | m_oldModemLock = _pppdata->modemLockFile(); |
356 | m_oldModemTimeout = _pppdata->modemTimeout(); | 340 | m_oldModemTimeout = _pppdata->modemTimeout(); |
341 | m_oldLineEnd = static_cast<int>( _pppdata->enter() ); | ||
357 | 342 | ||
358 | 343 | ||
359 | _pppdata->setModemDevice( modemdevice->currentText() ); | 344 | _pppdata->setModemDevice( modemdevice->currentText() ); |
360 | _pppdata->setFlowcontrol(flowcontrol->currentText()); | 345 | _pppdata->setFlowcontrol(static_cast<PPPData::FlowControl>(flowcontrol->currentItem())); |
361 | _pppdata->setFlowcontrol(flowcontrol->currentText()); | 346 | _pppdata->setEnter(static_cast<PPPData::LineTermination>(enter->currentItem())); |
362 | _pppdata->setSpeed(baud_c->currentText()); | 347 | _pppdata->setSpeed(baud_c->currentText()); |
363 | _pppdata->setModemLockFile( modemlockfile->isChecked()); | 348 | _pppdata->setModemLockFile( modemlockfile->isChecked()); |
364 | _pppdata->setModemTimeout( modemtimeout->value() ); | 349 | _pppdata->setModemTimeout( modemtimeout->value() ); |
365 | } | 350 | } |
366 | 351 | ||
367 | 352 | ||
368 | void ModemWidget::slotAfterModemQuery() | 353 | void ModemWidget::slotAfterModemQuery() |
369 | { | 354 | { |
370 | _pppdata->setModemDevice( m_oldModemDev ); | 355 | _pppdata->setModemDevice( m_oldModemDev ); |
371 | _pppdata->setFlowcontrol( m_oldFlowControl ); | 356 | _pppdata->setFlowcontrol( static_cast<PPPData::FlowControl>(m_oldFlowControl) ); |
357 | _pppdata->setEnter( static_cast<PPPData::LineTermination>(m_oldLineEnd) ); | ||
372 | _pppdata->setSpeed( m_oldSpeed ); | 358 | _pppdata->setSpeed( m_oldSpeed ); |
373 | _pppdata->setModemLockFile( m_oldModemLock ); | 359 | _pppdata->setModemLockFile( m_oldModemLock ); |
374 | _pppdata->setModemTimeout( m_oldModemTimeout ); | 360 | _pppdata->setModemTimeout( m_oldModemTimeout ); |
375 | } | 361 | } |
376 | 362 | ||
377 | 363 | ||
378 | ModemWidget2::ModemWidget2( PPPData *pd, InterfacePPP *ip, QWidget *parent, | 364 | ModemWidget2::ModemWidget2( PPPData *pd, InterfacePPP *ip, QWidget *parent, |
379 | const char *name) | 365 | const char *name) |
380 | : QWidget(parent, name), _pppdata(pd), _ifaceppp(ip) | 366 | : QWidget(parent, name), _pppdata(pd), _ifaceppp(ip) |
381 | { | 367 | { |
382 | QVBoxLayout *l1 = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); | 368 | QVBoxLayout *l1 = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); |
383 | 369 | ||
384 | 370 | ||
385 | waitfordt = new QCheckBox(tr("&Wait for dial tone before dialing"), this); | 371 | waitfordt = new QCheckBox(tr("&Wait for dial tone before dialing"), this); |
386 | waitfordt->setChecked(_pppdata->waitForDialTone()); | 372 | waitfordt->setChecked(_pppdata->waitForDialTone()); |
387 | // connect(waitfordt, SIGNAL(toggled(bool)), SLOT(waitfordtchanged(bool))); | 373 | // connect(waitfordt, SIGNAL(toggled(bool)), SLOT(waitfordtchanged(bool))); |
388 | l1->addWidget(waitfordt); | 374 | l1->addWidget(waitfordt); |
389 | QWhatsThis::add(waitfordt, | 375 | QWhatsThis::add(waitfordt, |
390 | tr("<p>Normally the modem waits for a dial tone\n" | 376 | tr("<p>Normally the modem waits for a dial tone\n" |
391 | "from your phone line, indicating that it can\n" | 377 | "from your phone line, indicating that it can\n" |
392 | "start to dial a number. If your modem does not\n" | 378 | "start to dial a number. If your modem does not\n" |
393 | "recognize this sound, or your local phone system\n" | 379 | "recognize this sound, or your local phone system\n" |
394 | "does not emit such a tone, uncheck this option\n" | 380 | "does not emit such a tone, uncheck this option\n" |
395 | "\n" | 381 | "\n" |
396 | "<b>Default:</b>: On")); | 382 | "<b>Default:</b>: On")); |
397 | 383 | ||
398 | QHBoxLayout *waitLayout = new QHBoxLayout( this ); | 384 | QHBoxLayout *waitLayout = new QHBoxLayout( this ); |
399 | QLabel *waitLabel = new QLabel( tr("Busy wait:"), this, "busyWait" ); | 385 | QLabel *waitLabel = new QLabel( tr("Busy wait:"), this, "busyWait" ); |
400 | busywait = new QSpinBox( 0, 300, 5, this, "busyWait" ); | 386 | busywait = new QSpinBox( 0, 300, 5, this, "busyWait" ); |
401 | // busywait = new KIntNumInput(_pppdata->busyWait(), this); | 387 | // busywait = new KIntNumInput(_pppdata->busyWait(), this); |
402 | // busywait->setLabel(tr("B&usy wait:")); | 388 | // busywait->setLabel(tr("B&usy wait:")); |
403 | // busywait->setRange(0, 300, 5, true); | 389 | // busywait->setRange(0, 300, 5, true); |
404 | busywait->setSuffix(tr(" sec")); | 390 | busywait->setSuffix(tr(" sec")); |
405 | // connect(busywait, SIGNAL(valueChanged(int)), SLOT(busywaitchanged(int))); | 391 | // connect(busywait, SIGNAL(valueChanged(int)), SLOT(busywaitchanged(int))); |
406 | waitLayout->addWidget(waitLabel); | 392 | waitLayout->addWidget(waitLabel); |
407 | waitLayout->addWidget(busywait); | 393 | waitLayout->addWidget(busywait); |
408 | l1->addLayout( waitLayout ); | 394 | l1->addLayout( waitLayout ); |
409 | 395 | ||
410 | QWhatsThis::add(busywait, | 396 | QWhatsThis::add(busywait, |
411 | tr("Specifies the number of seconds to wait before\n" | 397 | tr("Specifies the number of seconds to wait before\n" |
412 | "redial if all dialed numbers are busy. This is\n" | 398 | "redial if all dialed numbers are busy. This is\n" |
413 | "necessary because some modems get stuck if the\n" | 399 | "necessary because some modems get stuck if the\n" |
414 | "same number is busy too often.\n" | 400 | "same number is busy too often.\n" |
415 | "\n" | 401 | "\n" |
416 | "The default is 0 seconds, you should not change\n" | 402 | "The default is 0 seconds, you should not change\n" |
417 | "this unless you need to.")); | 403 | "this unless you need to.")); |
418 | 404 | ||
419 | l1->addSpacing(10); | 405 | l1->addSpacing(10); |
420 | 406 | ||
421 | QHBoxLayout *hbl = new QHBoxLayout; | 407 | QHBoxLayout *hbl = new QHBoxLayout; |
422 | hbl->setSpacing(2);//KDialog::spacingHint()); | 408 | hbl->setSpacing(2);//KDialog::spacingHint()); |
423 | 409 | ||
424 | QLabel *volumeLabel = new QLabel(tr("Modem &volume:"), this); | 410 | QLabel *volumeLabel = new QLabel(tr("Modem &volume:"), this); |
425 | hbl->addWidget(volumeLabel); | 411 | hbl->addWidget(volumeLabel); |
426 | volume = new QSlider(0, 2, 1, _pppdata->volume(), | 412 | volume = new QSlider(0, 2, 1, _pppdata->volume(), |
427 | QSlider::Horizontal, this); | 413 | QSlider::Horizontal, this); |
428 | volumeLabel->setBuddy(volume); | 414 | volumeLabel->setBuddy(volume); |
429 | volume->setTickmarks(QSlider::Below); | 415 | volume->setTickmarks(QSlider::Below); |
430 | hbl->addWidget(volume); | 416 | hbl->addWidget(volume); |
431 | 417 | ||
432 | l1->addLayout(hbl); | 418 | l1->addLayout(hbl); |
433 | 419 | ||
434 | // connect(volume, SIGNAL(valueChanged(int)), | 420 | // connect(volume, SIGNAL(valueChanged(int)), |
435 | // this, SLOT(volumeChanged(int))); | 421 | // this, SLOT(volumeChanged(int))); |
436 | QString tmp = tr("Most modems have a speaker which makes\n" | 422 | QString tmp = tr("Most modems have a speaker which makes\n" |
437 | "a lot of noise when dialing. Here you can\n" | 423 | "a lot of noise when dialing. Here you can\n" |
438 | "either turn this completely off or select a\n" | 424 | "either turn this completely off or select a\n" |
439 | "lower volume.\n" | 425 | "lower volume.\n" |
440 | "\n" | 426 | "\n" |
441 | "If this does not work for your modem,\n" | 427 | "If this does not work for your modem,\n" |
442 | "you must modify the modem volume command."); | 428 | "you must modify the modem volume command."); |
443 | 429 | ||
444 | QWhatsThis::add(volumeLabel,tmp); | 430 | QWhatsThis::add(volumeLabel,tmp); |
445 | QWhatsThis::add(volume, tmp); | 431 | QWhatsThis::add(volume, tmp); |
446 | 432 | ||
447 | l1->addSpacing(20); | 433 | l1->addSpacing(20); |
448 | 434 | ||
449 | #if 0 | 435 | #if 0 |
450 | chkbox1 = new QCheckBox(tr("Modem asserts CD line"), this); | 436 | chkbox1 = new QCheckBox(tr("Modem asserts CD line"), this); |
451 | chkbox1->setChecked(_pppdata->UseCDLine()); | 437 | chkbox1->setChecked(_pppdata->UseCDLine()); |
452 | connect(chkbox1,SIGNAL(toggled(bool)), | 438 | connect(chkbox1,SIGNAL(toggled(bool)), |
453 | this,SLOT(use_cdline_toggled(bool))); | 439 | this,SLOT(use_cdline_toggled(bool))); |
454 | l12->addWidget(chkbox1); | 440 | l12->addWidget(chkbox1); |
455 | l12->addStretch(1); | 441 | l12->addStretch(1); |
456 | l1->addStretch(1); | 442 | l1->addStretch(1); |
457 | QWhatsThis::add(chkbox1, | 443 | QWhatsThis::add(chkbox1, |
458 | tr("This controls how <i>kppp</i> detects that the modem\n" | 444 | tr("This controls how <i>kppp</i> detects that the modem\n" |
459 | "is not responding. Unless you are having\n" | 445 | "is not responding. Unless you are having\n" |
460 | "problems with this, do not modify this setting.\n" | 446 | "problems with this, do not modify this setting.\n" |
461 | "\n" | 447 | "\n" |
462 | "<b>Default</b>: Off")); | 448 | "<b>Default</b>: Off")); |
463 | #endif | 449 | #endif |
464 | 450 | ||
465 | modemcmds = new QPushButton(tr("Mod&em Commands..."), this); | 451 | modemcmds = new QPushButton(tr("Mod&em Commands..."), this); |
466 | QWhatsThis::add(modemcmds, | 452 | QWhatsThis::add(modemcmds, |
467 | tr("Allows you to change the AT command for\n" | 453 | tr("Allows you to change the AT command for\n" |
diff --git a/noncore/settings/networksettings/ppp/general.h b/noncore/settings/networksettings/ppp/general.h index a4dece4..0bb3136 100644 --- a/noncore/settings/networksettings/ppp/general.h +++ b/noncore/settings/networksettings/ppp/general.h | |||
@@ -1,125 +1,125 @@ | |||
1 | /* | 1 | /* |
2 | * | 2 | * |
3 | * kPPP: A pppd front end for the KDE project | 3 | * kPPP: A pppd front end for the KDE project |
4 | * | 4 | * |
5 | * $Id$ | 5 | * $Id$ |
6 | * | 6 | * |
7 | * Copyright (C) 1997 Bernd Johannes Wuebben | 7 | * Copyright (C) 1997 Bernd Johannes Wuebben |
8 | * wuebben@math.cornell.edu | 8 | * wuebben@math.cornell.edu |
9 | * | 9 | * |
10 | * | 10 | * |
11 | * This program is free software; you can redistribute it and/or | 11 | * This program is free software; you can redistribute it and/or |
12 | * modify it under the terms of the GNU Library General Public | 12 | * modify it under the terms of the GNU Library General Public |
13 | * License as published by the Free Software Foundation; either | 13 | * License as published by the Free Software Foundation; either |
14 | * version 2 of the License, or (at your option) any later version. | 14 | * version 2 of the License, or (at your option) any later version. |
15 | * | 15 | * |
16 | * This program is distributed in the hope that it will be useful, | 16 | * This program is distributed in the hope that it will be useful, |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
19 | * Library General Public License for more details. | 19 | * Library General Public License for more details. |
20 | * | 20 | * |
21 | * You should have received a copy of the GNU Library General Public | 21 | * You should have received a copy of the GNU Library General Public |
22 | * License along with this program; if not, write to the Free | 22 | * License along with this program; if not, write to the Free |
23 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 23 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #ifndef _GENERAL_H_ | 26 | #ifndef _GENERAL_H_ |
27 | #define _GENERAL_H_ | 27 | #define _GENERAL_H_ |
28 | 28 | ||
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | 30 | ||
31 | class QSlider; | 31 | class QSlider; |
32 | class QSpinBox; | 32 | class QSpinBox; |
33 | class QCombobox; | 33 | class QCombobox; |
34 | class QLabel; | 34 | class QLabel; |
35 | class QCheckBox; | 35 | class QCheckBox; |
36 | class QComboBox; | 36 | class QComboBox; |
37 | class PPPData; | 37 | class PPPData; |
38 | class InterfacePPP; | 38 | class InterfacePPP; |
39 | class QLineEdit; | 39 | class QLineEdit; |
40 | 40 | ||
41 | class ModemWidget : public QWidget { | 41 | class ModemWidget : public QWidget { |
42 | Q_OBJECT | 42 | Q_OBJECT |
43 | public: | 43 | public: |
44 | ModemWidget(PPPData*, QWidget *parent=0, const char *name=0 ); | 44 | ModemWidget(PPPData*, QWidget *parent=0, const char *name=0 ); |
45 | ~ModemWidget(); | 45 | ~ModemWidget(); |
46 | 46 | ||
47 | bool save(); | 47 | bool save(); |
48 | 48 | ||
49 | private slots: | 49 | private slots: |
50 | /* | 50 | /* |
51 | * temporarily commit configuration so queryModem | 51 | * temporarily commit configuration so queryModem |
52 | * will use 'current' settings | 52 | * will use 'current' settings |
53 | */ | 53 | */ |
54 | void slotBeforeModemQuery(); | 54 | void slotBeforeModemQuery(); |
55 | void slotAfterModemQuery(); | 55 | void slotAfterModemQuery(); |
56 | 56 | ||
57 | /* private slots: */ | 57 | /* private slots: */ |
58 | /* void setmodemdc(int); */ | 58 | /* void setmodemdc(int); */ |
59 | /* void setmodemdc(const QString &); */ | 59 | /* void setmodemdc(const QString &); */ |
60 | /* void setflowcontrol(int); */ | 60 | /* void setflowcontrol(int); */ |
61 | /* void modemtimeoutchanged(int); */ | 61 | /* void modemtimeoutchanged(int); */ |
62 | /* void modemlockfilechanged(bool); */ | 62 | /* void modemlockfilechanged(bool); */ |
63 | /* void setenter(int); */ | 63 | /* void setenter(int); */ |
64 | /* void speed_selection(int); */ | 64 | /* void speed_selection(int); */ |
65 | 65 | ||
66 | private: | 66 | private: |
67 | QComboBox *enter; | 67 | QComboBox *enter; |
68 | /* QLabel *label1; */ | 68 | /* QLabel *label1; */ |
69 | /* QLabel *label2; */ | 69 | /* QLabel *label2; */ |
70 | /* QLabel *labeltmp; */ | 70 | /* QLabel *labeltmp; */ |
71 | /* QLabel *labelenter; */ | 71 | /* QLabel *labelenter; */ |
72 | QLineEdit *modemname; | 72 | QLineEdit *modemname; |
73 | QComboBox *modemdevice; | 73 | QComboBox *modemdevice; |
74 | QComboBox *flowcontrol; | 74 | QComboBox *flowcontrol; |
75 | 75 | ||
76 | QComboBox *baud_c; | 76 | QComboBox *baud_c; |
77 | QLabel *baud_label; | 77 | QLabel *baud_label; |
78 | 78 | ||
79 | QSpinBox *modemtimeout; | 79 | QSpinBox *modemtimeout; |
80 | QCheckBox *modemlockfile; | 80 | QCheckBox *modemlockfile; |
81 | PPPData *_pppdata; | 81 | PPPData *_pppdata; |
82 | 82 | ||
83 | private: | 83 | private: |
84 | QString m_oldModemDev, m_oldFlowControl, m_oldSpeed; | 84 | QString m_oldModemDev, m_oldSpeed; |
85 | bool m_oldModemLock; | 85 | bool m_oldModemLock; |
86 | int m_oldModemTimeout; | 86 | int m_oldModemTimeout, m_oldFlowControl, m_oldLineEnd; |
87 | }; | 87 | }; |
88 | 88 | ||
89 | 89 | ||
90 | class ModemWidget2 : public QWidget { | 90 | class ModemWidget2 : public QWidget { |
91 | Q_OBJECT | 91 | Q_OBJECT |
92 | public: | 92 | public: |
93 | ModemWidget2( PPPData*, InterfacePPP*, QWidget *parent=0, const char *name=0 ); | 93 | ModemWidget2( PPPData*, InterfacePPP*, QWidget *parent=0, const char *name=0 ); |
94 | bool save(); | 94 | bool save(); |
95 | 95 | ||
96 | signals: | 96 | signals: |
97 | void sig_beforeQueryModem(); | 97 | void sig_beforeQueryModem(); |
98 | void sig_afterQueryModem(); | 98 | void sig_afterQueryModem(); |
99 | 99 | ||
100 | private slots: | 100 | private slots: |
101 | /* void waitfordtchanged(bool); */ | 101 | /* void waitfordtchanged(bool); */ |
102 | /* void busywaitchanged(int); */ | 102 | /* void busywaitchanged(int); */ |
103 | // void use_cdline_toggled(bool); | 103 | // void use_cdline_toggled(bool); |
104 | void modemcmdsbutton(); | 104 | void modemcmdsbutton(); |
105 | // void terminal(); | 105 | // void terminal(); |
106 | void query_modem(); | 106 | void query_modem(); |
107 | // void volumeChanged(int); | 107 | // void volumeChanged(int); |
108 | 108 | ||
109 | private: | 109 | private: |
110 | QLabel *labeltmp; | 110 | QLabel *labeltmp; |
111 | QPushButton *modemcmds; | 111 | QPushButton *modemcmds; |
112 | QPushButton *modeminfo_button; | 112 | QPushButton *modeminfo_button; |
113 | // QPushButton *terminal_button; | 113 | // QPushButton *terminal_button; |
114 | // QFrame *fline; | 114 | // QFrame *fline; |
115 | QCheckBox *waitfordt; | 115 | QCheckBox *waitfordt; |
116 | QSpinBox *busywait; | 116 | QSpinBox *busywait; |
117 | QCheckBox *chkbox1; | 117 | QCheckBox *chkbox1; |
118 | QSlider *volume; | 118 | QSlider *volume; |
119 | PPPData *_pppdata; | 119 | PPPData *_pppdata; |
120 | InterfacePPP *_ifaceppp; | 120 | InterfacePPP *_ifaceppp; |
121 | }; | 121 | }; |
122 | 122 | ||
123 | #endif | 123 | #endif |
124 | 124 | ||
125 | 125 | ||
diff --git a/noncore/settings/networksettings/ppp/modem.cpp b/noncore/settings/networksettings/ppp/modem.cpp index 79f015b..7b2e2a3 100644 --- a/noncore/settings/networksettings/ppp/modem.cpp +++ b/noncore/settings/networksettings/ppp/modem.cpp | |||
@@ -132,331 +132,335 @@ speed_t Modem::modemspeed() { | |||
132 | case 384: | 132 | case 384: |
133 | return B38400; | 133 | return B38400; |
134 | break; | 134 | break; |
135 | #ifdef B57600 | 135 | #ifdef B57600 |
136 | case 576: | 136 | case 576: |
137 | return B57600; | 137 | return B57600; |
138 | break; | 138 | break; |
139 | #endif | 139 | #endif |
140 | 140 | ||
141 | #ifdef B115200 | 141 | #ifdef B115200 |
142 | case 1152: | 142 | case 1152: |
143 | return B115200; | 143 | return B115200; |
144 | break; | 144 | break; |
145 | #endif | 145 | #endif |
146 | 146 | ||
147 | #ifdef B230400 | 147 | #ifdef B230400 |
148 | case 2304: | 148 | case 2304: |
149 | return B230400; | 149 | return B230400; |
150 | break; | 150 | break; |
151 | #endif | 151 | #endif |
152 | 152 | ||
153 | #ifdef B460800 | 153 | #ifdef B460800 |
154 | case 4608: | 154 | case 4608: |
155 | return B460800; | 155 | return B460800; |
156 | break; | 156 | break; |
157 | #endif | 157 | #endif |
158 | 158 | ||
159 | default: | 159 | default: |
160 | return B38400; | 160 | return B38400; |
161 | break; | 161 | break; |
162 | } | 162 | } |
163 | } | 163 | } |
164 | 164 | ||
165 | bool Modem::opentty() { | 165 | bool Modem::opentty() { |
166 | // int flags; | 166 | // int flags; |
167 | 167 | ||
168 | //begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { | 168 | //begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { |
169 | close(modemfd); | 169 | close(modemfd); |
170 | device = _pppdata->modemDevice(); | 170 | device = _pppdata->modemDevice(); |
171 | if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) { | 171 | if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) { |
172 | odebug << "error opening modem device !" << oendl; | 172 | odebug << "error opening modem device !" << oendl; |
173 | errmsg = QObject::tr("Unable to open modem."); | 173 | errmsg = QObject::tr("Unable to open modem."); |
174 | return false; | 174 | return false; |
175 | } | 175 | } |
176 | //bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { | 176 | //bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { |
177 | //} | 177 | //} |
178 | 178 | ||
179 | #if 0 | 179 | #if 0 |
180 | if(_pppdata->UseCDLine()) { | 180 | if(_pppdata->UseCDLine()) { |
181 | if(ioctl(modemfd, TIOCMGET, &flags) == -1) { | 181 | if(ioctl(modemfd, TIOCMGET, &flags) == -1) { |
182 | errmsg = QObject::tr("Unable to detect state of CD line."); | 182 | errmsg = QObject::tr("Unable to detect state of CD line."); |
183 | ::close(modemfd); | 183 | ::close(modemfd); |
184 | modemfd = -1; | 184 | modemfd = -1; |
185 | return false; | 185 | return false; |
186 | } | 186 | } |
187 | if ((flags&TIOCM_CD) == 0) { | 187 | if ((flags&TIOCM_CD) == 0) { |
188 | errmsg = QObject::tr("The modem is not ready."); | 188 | errmsg = QObject::tr("The modem is not ready."); |
189 | ::close(modemfd); | 189 | ::close(modemfd); |
190 | modemfd = -1; | 190 | modemfd = -1; |
191 | return false; | 191 | return false; |
192 | } | 192 | } |
193 | } | 193 | } |
194 | #endif | 194 | #endif |
195 | 195 | ||
196 | tcdrain (modemfd); | 196 | tcdrain (modemfd); |
197 | tcflush (modemfd, TCIOFLUSH); | 197 | tcflush (modemfd, TCIOFLUSH); |
198 | 198 | ||
199 | if(tcgetattr(modemfd, &tty) < 0){ | 199 | if(tcgetattr(modemfd, &tty) < 0){ |
200 | // this helps in some cases | 200 | // this helps in some cases |
201 | tcsendbreak(modemfd, 0); | 201 | tcsendbreak(modemfd, 0); |
202 | sleep(1); | 202 | sleep(1); |
203 | if(tcgetattr(modemfd, &tty) < 0){ | 203 | if(tcgetattr(modemfd, &tty) < 0){ |
204 | errmsg = QObject::tr("The modem is busy."); | 204 | errmsg = QObject::tr("The modem is busy."); |
205 | ::close(modemfd); | 205 | ::close(modemfd); |
206 | modemfd = -1; | 206 | modemfd = -1; |
207 | return false; | 207 | return false; |
208 | } | 208 | } |
209 | } | 209 | } |
210 | 210 | ||
211 | memset(&initial_tty,'\0',sizeof(initial_tty)); | 211 | memset(&initial_tty,'\0',sizeof(initial_tty)); |
212 | 212 | ||
213 | initial_tty = tty; | 213 | initial_tty = tty; |
214 | 214 | ||
215 | tty.c_cc[VMIN] = 0; // nonblocking | 215 | tty.c_cc[VMIN] = 0; // nonblocking |
216 | tty.c_cc[VTIME] = 0; | 216 | tty.c_cc[VTIME] = 0; |
217 | tty.c_oflag = 0; | 217 | tty.c_oflag = 0; |
218 | tty.c_lflag = 0; | 218 | tty.c_lflag = 0; |
219 | 219 | ||
220 | tty.c_cflag &= ~(CSIZE | CSTOPB | PARENB); | 220 | tty.c_cflag &= ~(CSIZE | CSTOPB | PARENB); |
221 | tty.c_cflag |= CS8 | CREAD; | 221 | tty.c_cflag |= CS8 | CREAD; |
222 | tty.c_cflag |= CLOCAL; // ignore modem status lines | 222 | tty.c_cflag |= CLOCAL; // ignore modem status lines |
223 | tty.c_iflag = IGNBRK | IGNPAR /* | ISTRIP */ ; | 223 | tty.c_iflag = IGNBRK | IGNPAR /* | ISTRIP */ ; |
224 | tty.c_lflag &= ~ICANON; // non-canonical mode | 224 | tty.c_lflag &= ~ICANON; // non-canonical mode |
225 | tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHOKE); | 225 | tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHOKE); |
226 | 226 | ||
227 | 227 | ||
228 | if(_pppdata->flowcontrol() != "None") { | 228 | if(_pppdata->flowcontrol() != PPPData::FlowNone) { |
229 | if(_pppdata->flowcontrol() == "CRTSCTS") { | 229 | if(_pppdata->flowcontrol() == PPPData::FlowHardware) { |
230 | tty.c_cflag |= CRTSCTS; | 230 | tty.c_cflag |= CRTSCTS; |
231 | } | 231 | } |
232 | else { | 232 | else { |
233 | tty.c_iflag |= IXON | IXOFF; | 233 | tty.c_iflag |= IXON | IXOFF; |
234 | tty.c_cc[VSTOP] = 0x13; /* DC3 = XOFF = ^S */ | 234 | tty.c_cc[VSTOP] = 0x13; /* DC3 = XOFF = ^S */ |
235 | tty.c_cc[VSTART] = 0x11; /* DC1 = XON = ^Q */ | 235 | tty.c_cc[VSTART] = 0x11; /* DC1 = XON = ^Q */ |
236 | } | 236 | } |
237 | } | 237 | } |
238 | else { | 238 | else { |
239 | tty.c_cflag &= ~CRTSCTS; | 239 | tty.c_cflag &= ~CRTSCTS; |
240 | tty.c_iflag &= ~(IXON | IXOFF); | 240 | tty.c_iflag &= ~(IXON | IXOFF); |
241 | } | 241 | } |
242 | 242 | ||
243 | cfsetospeed(&tty, modemspeed()); | 243 | cfsetospeed(&tty, modemspeed()); |
244 | cfsetispeed(&tty, modemspeed()); | 244 | cfsetispeed(&tty, modemspeed()); |
245 | 245 | ||
246 | tcdrain(modemfd); | 246 | tcdrain(modemfd); |
247 | 247 | ||
248 | if(tcsetattr(modemfd, TCSANOW, &tty) < 0){ | 248 | if(tcsetattr(modemfd, TCSANOW, &tty) < 0){ |
249 | errmsg = QObject::tr("The modem is busy."); | 249 | errmsg = QObject::tr("The modem is busy."); |
250 | ::close(modemfd); | 250 | ::close(modemfd); |
251 | modemfd=-1; | 251 | modemfd=-1; |
252 | return false; | 252 | return false; |
253 | } | 253 | } |
254 | 254 | ||
255 | errmsg = QObject::tr("Modem Ready."); | 255 | errmsg = QObject::tr("Modem Ready."); |
256 | return true; | 256 | return true; |
257 | } | 257 | } |
258 | 258 | ||
259 | 259 | ||
260 | bool Modem::closetty() { | 260 | bool Modem::closetty() { |
261 | if(modemfd >=0 ) { | 261 | if(modemfd >=0 ) { |
262 | stop(); | 262 | stop(); |
263 | /* discard data not read or transmitted */ | 263 | /* discard data not read or transmitted */ |
264 | tcflush(modemfd, TCIOFLUSH); | 264 | tcflush(modemfd, TCIOFLUSH); |
265 | 265 | ||
266 | if(tcsetattr(modemfd, TCSANOW, &initial_tty) < 0){ | 266 | if(tcsetattr(modemfd, TCSANOW, &initial_tty) < 0){ |
267 | errmsg = QObject::tr("Can't restore tty settings: tcsetattr()\n"); | 267 | errmsg = QObject::tr("Can't restore tty settings: tcsetattr()\n"); |
268 | ::close(modemfd); | 268 | ::close(modemfd); |
269 | modemfd = -1; | 269 | modemfd = -1; |
270 | return false; | 270 | return false; |
271 | } | 271 | } |
272 | ::close(modemfd); | 272 | ::close(modemfd); |
273 | modemfd = -1; | 273 | modemfd = -1; |
274 | } | 274 | } |
275 | 275 | ||
276 | return true; | 276 | return true; |
277 | } | 277 | } |
278 | 278 | ||
279 | 279 | ||
280 | void Modem::readtty(int) { | 280 | void Modem::readtty(int) { |
281 | char buffer[200]; | 281 | char buffer[200]; |
282 | unsigned char c; | 282 | unsigned char c; |
283 | int len; | 283 | int len; |
284 | 284 | ||
285 | // read data in chunks of up to 200 bytes | 285 | // read data in chunks of up to 200 bytes |
286 | if((len = ::read(modemfd, buffer, 200)) > 0) { | 286 | if((len = ::read(modemfd, buffer, 200)) > 0) { |
287 | // split buffer into single characters for further processing | 287 | // split buffer into single characters for further processing |
288 | for(int i = 0; i < len; i++) { | 288 | for(int i = 0; i < len; i++) { |
289 | c = buffer[i] & 0x7F; | 289 | c = buffer[i] & 0x7F; |
290 | emit charWaiting(c); | 290 | emit charWaiting(c); |
291 | } | 291 | } |
292 | } | 292 | } |
293 | } | 293 | } |
294 | 294 | ||
295 | 295 | ||
296 | void Modem::notify(const QObject *receiver, const char *member) { | 296 | void Modem::notify(const QObject *receiver, const char *member) { |
297 | connect(this, SIGNAL(charWaiting(unsigned char)), receiver, member); | 297 | connect(this, SIGNAL(charWaiting(unsigned char)), receiver, member); |
298 | startNotifier(); | 298 | startNotifier(); |
299 | } | 299 | } |
300 | 300 | ||
301 | 301 | ||
302 | void Modem::stop() { | 302 | void Modem::stop() { |
303 | disconnect(SIGNAL(charWaiting(unsigned char))); | 303 | disconnect(SIGNAL(charWaiting(unsigned char))); |
304 | stopNotifier(); | 304 | stopNotifier(); |
305 | } | 305 | } |
306 | 306 | ||
307 | 307 | ||
308 | void Modem::startNotifier() { | 308 | void Modem::startNotifier() { |
309 | if(modemfd >= 0) { | 309 | if(modemfd >= 0) { |
310 | if(sn == 0) { | 310 | if(sn == 0) { |
311 | sn = new QSocketNotifier(modemfd, QSocketNotifier::Read, this); | 311 | sn = new QSocketNotifier(modemfd, QSocketNotifier::Read, this); |
312 | connect(sn, SIGNAL(activated(int)), SLOT(readtty(int))); | 312 | connect(sn, SIGNAL(activated(int)), SLOT(readtty(int))); |
313 | odebug << "QSocketNotifier started!" << oendl; | 313 | odebug << "QSocketNotifier started!" << oendl; |
314 | } else { | 314 | } else { |
315 | odebug << "QSocketNotifier re-enabled!" << oendl; | 315 | odebug << "QSocketNotifier re-enabled!" << oendl; |
316 | sn->setEnabled(true); | 316 | sn->setEnabled(true); |
317 | } | 317 | } |
318 | } | 318 | } |
319 | } | 319 | } |
320 | 320 | ||
321 | 321 | ||
322 | void Modem::stopNotifier() { | 322 | void Modem::stopNotifier() { |
323 | if(sn != 0) { | 323 | if(sn != 0) { |
324 | sn->setEnabled(false); | 324 | sn->setEnabled(false); |
325 | disconnect(sn); | 325 | disconnect(sn); |
326 | delete sn; | 326 | delete sn; |
327 | sn = 0; | 327 | sn = 0; |
328 | odebug << "QSocketNotifier stopped!" << oendl; | 328 | odebug << "QSocketNotifier stopped!" << oendl; |
329 | } | 329 | } |
330 | } | 330 | } |
331 | 331 | ||
332 | 332 | ||
333 | void Modem::flush() { | 333 | void Modem::flush() { |
334 | char c; | 334 | char c; |
335 | while(read(modemfd, &c, 1) == 1); | 335 | while(read(modemfd, &c, 1) == 1); |
336 | } | 336 | } |
337 | 337 | ||
338 | 338 | ||
339 | bool Modem::writeChar(unsigned char c) { | 339 | bool Modem::writeChar(unsigned char c) { |
340 | int s; | 340 | int s; |
341 | do { | 341 | do { |
342 | s = write(modemfd, &c, 1); | 342 | s = write(modemfd, &c, 1); |
343 | if (s < 0) { | 343 | if (s < 0) { |
344 | oerr << "write() in Modem::writeChar failed" << oendl; | 344 | oerr << "write() in Modem::writeChar failed" << oendl; |
345 | return false; | 345 | return false; |
346 | } | 346 | } |
347 | } while(s == 0); | 347 | } while(s == 0); |
348 | 348 | ||
349 | return true; | 349 | return true; |
350 | } | 350 | } |
351 | 351 | ||
352 | 352 | ||
353 | bool Modem::writeLine(const char *buf) { | 353 | bool Modem::writeLine(const char *buf) { |
354 | int len = strlen(buf); | 354 | int len = strlen(buf); |
355 | char *b = new char[len+2]; | 355 | char *b = new char[len+2]; |
356 | memcpy(b, buf, len); | 356 | memcpy(b, buf, len); |
357 | // different modems seem to need different line terminations | 357 | // different modems seem to need different line terminations |
358 | QString term = _pppdata->enter(); | 358 | switch( _pppdata->enter() ) { |
359 | if(term == "LF") | 359 | case PPPData::EndLF: |
360 | b[len++]='\n'; | 360 | b[len++]='\n'; |
361 | else if(term == "CR") | 361 | break; |
362 | case PPPData::EndCR: | ||
362 | b[len++]='\r'; | 363 | b[len++]='\r'; |
363 | else if(term == "CR/LF") { | 364 | break; |
365 | case PPPData::EndCRLF: | ||
364 | b[len++]='\r'; | 366 | b[len++]='\r'; |
365 | b[len++]='\n'; | 367 | b[len++]='\n'; |
368 | break; | ||
366 | } | 369 | } |
370 | |||
367 | int l = len; | 371 | int l = len; |
368 | while(l) { | 372 | while(l) { |
369 | int wr = write(modemfd, &b[len-l], l); | 373 | int wr = write(modemfd, &b[len-l], l); |
370 | if(wr < 0) { | 374 | if(wr < 0) { |
371 | // TODO do something meaningful with the error code (or ignore it | 375 | // TODO do something meaningful with the error code (or ignore it |
372 | oerr << "write() in Modem::writeLine failed" << oendl; | 376 | oerr << "write() in Modem::writeLine failed" << oendl; |
373 | delete[] b; | 377 | delete[] b; |
374 | return false; | 378 | return false; |
375 | } | 379 | } |
376 | l -= wr; | 380 | l -= wr; |
377 | } | 381 | } |
378 | delete[] b; | 382 | delete[] b; |
379 | return true; | 383 | return true; |
380 | } | 384 | } |
381 | 385 | ||
382 | 386 | ||
383 | bool Modem::hangup() { | 387 | bool Modem::hangup() { |
384 | // this should really get the modem to hang up and go into command mode | 388 | // this should really get the modem to hang up and go into command mode |
385 | // If anyone sees a fault in the following please let me know, since | 389 | // If anyone sees a fault in the following please let me know, since |
386 | // this is probably the most imporant snippet of code in the whole of | 390 | // this is probably the most imporant snippet of code in the whole of |
387 | // kppp. If people complain about kppp being stuck, this piece of code | 391 | // kppp. If people complain about kppp being stuck, this piece of code |
388 | // is most likely the reason. | 392 | // is most likely the reason. |
389 | struct termios temptty; | 393 | struct termios temptty; |
390 | 394 | ||
391 | if(modemfd >= 0) { | 395 | if(modemfd >= 0) { |
392 | 396 | ||
393 | // is this Escape & HangupStr stuff really necessary ? (Harri) | 397 | // is this Escape & HangupStr stuff really necessary ? (Harri) |
394 | 398 | ||
395 | if (data_mode) escape_to_command_mode(); | 399 | if (data_mode) escape_to_command_mode(); |
396 | 400 | ||
397 | // Then hangup command | 401 | // Then hangup command |
398 | writeLine(_pppdata->modemHangupStr().local8Bit()); | 402 | writeLine(_pppdata->modemHangupStr().local8Bit()); |
399 | 403 | ||
400 | usleep(_pppdata->modemInitDelay() * 10000); // 0.01 - 3.0 sec | 404 | usleep(_pppdata->modemInitDelay() * 10000); // 0.01 - 3.0 sec |
401 | 405 | ||
402 | #ifndef DEBUG_WO_DIALING | 406 | #ifndef DEBUG_WO_DIALING |
403 | if (sigsetjmp(jmp_buffer, 1) == 0) { | 407 | if (sigsetjmp(jmp_buffer, 1) == 0) { |
404 | // set alarm in case tcsendbreak() hangs | 408 | // set alarm in case tcsendbreak() hangs |
405 | signal(SIGALRM, alarm_handler); | 409 | signal(SIGALRM, alarm_handler); |
406 | alarm(2); | 410 | alarm(2); |
407 | 411 | ||
408 | tcsendbreak(modemfd, 0); | 412 | tcsendbreak(modemfd, 0); |
409 | 413 | ||
410 | alarm(0); | 414 | alarm(0); |
411 | signal(SIGALRM, SIG_IGN); | 415 | signal(SIGALRM, SIG_IGN); |
412 | } else { | 416 | } else { |
413 | // we reach this point if the alarm handler got called | 417 | // we reach this point if the alarm handler got called |
414 | closetty(); | 418 | closetty(); |
415 | close(modemfd); | 419 | close(modemfd); |
416 | modemfd = -1; | 420 | modemfd = -1; |
417 | errmsg = QObject::tr("The modem does not respond."); | 421 | errmsg = QObject::tr("The modem does not respond."); |
418 | return false; | 422 | return false; |
419 | } | 423 | } |
420 | 424 | ||
421 | #ifndef __svr4__ // drops DTR but doesn't set it afterwards again. not good for init. | 425 | #ifndef __svr4__ // drops DTR but doesn't set it afterwards again. not good for init. |
422 | tcgetattr(modemfd, &temptty); | 426 | tcgetattr(modemfd, &temptty); |
423 | cfsetospeed(&temptty, B0); | 427 | cfsetospeed(&temptty, B0); |
424 | cfsetispeed(&temptty, B0); | 428 | cfsetispeed(&temptty, B0); |
425 | tcsetattr(modemfd, TCSAFLUSH, &temptty); | 429 | tcsetattr(modemfd, TCSAFLUSH, &temptty); |
426 | #else | 430 | #else |
427 | int modemstat; | 431 | int modemstat; |
428 | ioctl(modemfd, TIOCMGET, &modemstat); | 432 | ioctl(modemfd, TIOCMGET, &modemstat); |
429 | modemstat &= ~TIOCM_DTR; | 433 | modemstat &= ~TIOCM_DTR; |
430 | ioctl(modemfd, TIOCMSET, &modemstat); | 434 | ioctl(modemfd, TIOCMSET, &modemstat); |
431 | ioctl(modemfd, TIOCMGET, &modemstat); | 435 | ioctl(modemfd, TIOCMGET, &modemstat); |
432 | modemstat |= TIOCM_DTR; | 436 | modemstat |= TIOCM_DTR; |
433 | ioctl(modemfd, TIOCMSET, &modemstat); | 437 | ioctl(modemfd, TIOCMSET, &modemstat); |
434 | #endif | 438 | #endif |
435 | 439 | ||
436 | usleep(_pppdata->modemInitDelay() * 10000); // 0.01 - 3.0 secs | 440 | usleep(_pppdata->modemInitDelay() * 10000); // 0.01 - 3.0 secs |
437 | 441 | ||
438 | cfsetospeed(&temptty, modemspeed()); | 442 | cfsetospeed(&temptty, modemspeed()); |
439 | cfsetispeed(&temptty, modemspeed()); | 443 | cfsetispeed(&temptty, modemspeed()); |
440 | tcsetattr(modemfd, TCSAFLUSH, &temptty); | 444 | tcsetattr(modemfd, TCSAFLUSH, &temptty); |
441 | #endif | 445 | #endif |
442 | return true; | 446 | return true; |
443 | } else | 447 | } else |
444 | return false; | 448 | return false; |
445 | } | 449 | } |
446 | 450 | ||
447 | 451 | ||
448 | void Modem::escape_to_command_mode() { | 452 | void Modem::escape_to_command_mode() { |
449 | // Send Properly bracketed escape code to put the modem back into command state. | 453 | // Send Properly bracketed escape code to put the modem back into command state. |
450 | // A modem will accept AT commands only when it is in command state. | 454 | // A modem will accept AT commands only when it is in command state. |
451 | // When a modem sends the host the CONNECT string, that signals | 455 | // When a modem sends the host the CONNECT string, that signals |
452 | // that the modem is now in the connect state (no long accepts AT commands.) | 456 | // that the modem is now in the connect state (no long accepts AT commands.) |
453 | // Need to send properly timed escape sequence to put modem in command state. | 457 | // Need to send properly timed escape sequence to put modem in command state. |
454 | // Escape codes and guard times are controlled by S2 and S12 values. | 458 | // Escape codes and guard times are controlled by S2 and S12 values. |
455 | // | 459 | // |
456 | tcflush(modemfd, TCIOFLUSH); | 460 | tcflush(modemfd, TCIOFLUSH); |
457 | 461 | ||
458 | // +3 because quiet time must be greater than guard time. | 462 | // +3 because quiet time must be greater than guard time. |
459 | usleep((_pppdata->modemEscapeGuardTime()+3)*20000); | 463 | usleep((_pppdata->modemEscapeGuardTime()+3)*20000); |
460 | QCString tmp = _pppdata->modemEscapeStr().local8Bit(); | 464 | QCString tmp = _pppdata->modemEscapeStr().local8Bit(); |
461 | write(modemfd, tmp.data(), tmp.length()); | 465 | write(modemfd, tmp.data(), tmp.length()); |
462 | tcflush(modemfd, TCIOFLUSH); | 466 | tcflush(modemfd, TCIOFLUSH); |
diff --git a/noncore/settings/networksettings/ppp/pppdata.cpp b/noncore/settings/networksettings/ppp/pppdata.cpp index eb03ef4..1491ea2 100644 --- a/noncore/settings/networksettings/ppp/pppdata.cpp +++ b/noncore/settings/networksettings/ppp/pppdata.cpp | |||
@@ -294,198 +294,198 @@ void PPPData::set_quit_on_disconnect(bool set) { | |||
294 | writeConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, (int) set); | 294 | writeConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, (int) set); |
295 | } | 295 | } |
296 | 296 | ||
297 | 297 | ||
298 | bool PPPData::get_show_log_window() { | 298 | bool PPPData::get_show_log_window() { |
299 | return (bool) readNumConfig (GENERAL_GRP, SHOWLOGWIN_KEY, false); | 299 | return (bool) readNumConfig (GENERAL_GRP, SHOWLOGWIN_KEY, false); |
300 | } | 300 | } |
301 | 301 | ||
302 | 302 | ||
303 | void PPPData::set_show_log_window(bool set) { | 303 | void PPPData::set_show_log_window(bool set) { |
304 | writeConfig(GENERAL_GRP, SHOWLOGWIN_KEY, (int) set); | 304 | writeConfig(GENERAL_GRP, SHOWLOGWIN_KEY, (int) set); |
305 | } | 305 | } |
306 | 306 | ||
307 | 307 | ||
308 | bool PPPData::automatic_redial() { | 308 | bool PPPData::automatic_redial() { |
309 | return (bool) readNumConfig(GENERAL_GRP, AUTOREDIAL_KEY, FALSE); | 309 | return (bool) readNumConfig(GENERAL_GRP, AUTOREDIAL_KEY, FALSE); |
310 | } | 310 | } |
311 | 311 | ||
312 | 312 | ||
313 | void PPPData::set_automatic_redial(bool set) { | 313 | void PPPData::set_automatic_redial(bool set) { |
314 | writeConfig(GENERAL_GRP, AUTOREDIAL_KEY, (int) set); | 314 | writeConfig(GENERAL_GRP, AUTOREDIAL_KEY, (int) set); |
315 | } | 315 | } |
316 | 316 | ||
317 | 317 | ||
318 | // bool PPPData::get_iconify_on_connect() { | 318 | // bool PPPData::get_iconify_on_connect() { |
319 | // return (bool) readNumConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, TRUE); | 319 | // return (bool) readNumConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, TRUE); |
320 | // } | 320 | // } |
321 | 321 | ||
322 | 322 | ||
323 | // void PPPData::set_iconify_on_connect(bool set) { | 323 | // void PPPData::set_iconify_on_connect(bool set) { |
324 | // writeConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, (int) set); | 324 | // writeConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, (int) set); |
325 | // } | 325 | // } |
326 | 326 | ||
327 | 327 | ||
328 | // bool PPPData::get_dock_into_panel() { | 328 | // bool PPPData::get_dock_into_panel() { |
329 | // return (bool) readNumConfig(GENERAL_GRP, DOCKING_KEY, false); | 329 | // return (bool) readNumConfig(GENERAL_GRP, DOCKING_KEY, false); |
330 | // } | 330 | // } |
331 | 331 | ||
332 | 332 | ||
333 | // void PPPData::set_dock_into_panel(bool set) { | 333 | // void PPPData::set_dock_into_panel(bool set) { |
334 | // writeConfig(GENERAL_GRP, DOCKING_KEY, (int) set); | 334 | // writeConfig(GENERAL_GRP, DOCKING_KEY, (int) set); |
335 | // } | 335 | // } |
336 | 336 | ||
337 | 337 | ||
338 | QString PPPData::pppdVersion() { | 338 | QString PPPData::pppdVersion() { |
339 | return QString("%1.%2.%3").arg(pppdVer).arg(pppdMod).arg(pppdPatch); | 339 | return QString("%1.%2.%3").arg(pppdVer).arg(pppdMod).arg(pppdPatch); |
340 | } | 340 | } |
341 | 341 | ||
342 | bool PPPData::pppdVersionMin(int ver, int mod, int patch) { | 342 | bool PPPData::pppdVersionMin(int ver, int mod, int patch) { |
343 | // check if pppd version fulfills minimum requirement | 343 | // check if pppd version fulfills minimum requirement |
344 | return (pppdVer > ver | 344 | return (pppdVer > ver |
345 | || (pppdVer == ver && pppdMod > mod) | 345 | || (pppdVer == ver && pppdMod > mod) |
346 | || (pppdVer == ver && pppdMod == mod && pppdPatch >= patch)); | 346 | || (pppdVer == ver && pppdMod == mod && pppdPatch >= patch)); |
347 | } | 347 | } |
348 | 348 | ||
349 | int PPPData::pppdTimeout() { | 349 | int PPPData::pppdTimeout() { |
350 | return readNumConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, PPPD_TIMEOUT); | 350 | return readNumConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, PPPD_TIMEOUT); |
351 | } | 351 | } |
352 | 352 | ||
353 | 353 | ||
354 | void PPPData::setpppdTimeout(int n) { | 354 | void PPPData::setpppdTimeout(int n) { |
355 | writeConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, n); | 355 | writeConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, n); |
356 | } | 356 | } |
357 | 357 | ||
358 | 358 | ||
359 | const QString PPPData::modemDevice() { | 359 | const QString PPPData::modemDevice() { |
360 | return readConfig (modemGroup(), MODEMDEV_KEY, "/dev/modem" ); | 360 | return readConfig (modemGroup(), MODEMDEV_KEY, "/dev/modem" ); |
361 | } | 361 | } |
362 | 362 | ||
363 | 363 | ||
364 | // const QString PPPData::modemName() | 364 | // const QString PPPData::modemName() |
365 | // { | 365 | // { |
366 | // return readConfig(modemGroup(), MODEMNAME_KEY); | 366 | // return readConfig(modemGroup(), MODEMNAME_KEY); |
367 | // } | 367 | // } |
368 | 368 | ||
369 | // bool PPPData::setModemName(const QString &n) { | 369 | // bool PPPData::setModemName(const QString &n) { |
370 | // odebug << "Setting modem name to >" << n.latin1() << "<" << oendl; | 370 | // odebug << "Setting modem name to >" << n.latin1() << "<" << oendl; |
371 | // _modemName = n; | 371 | // _modemName = n; |
372 | // writeConfig(cgroup, MODEMNAME_KEY, n); | 372 | // writeConfig(cgroup, MODEMNAME_KEY, n); |
373 | // return true; //FIXME | 373 | // return true; //FIXME |
374 | // } | 374 | // } |
375 | 375 | ||
376 | // bool PPPData::changeModemName(const QString &n) { | 376 | // bool PPPData::changeModemName(const QString &n) { |
377 | // odebug << "Setting modem name to >" << n.latin1() << "<" << oendl; | 377 | // odebug << "Setting modem name to >" << n.latin1() << "<" << oendl; |
378 | // _modemName = n; | 378 | // _modemName = n; |
379 | // writeConfig(modemGroup(), MODEMNAME_KEY, n); | 379 | // writeConfig(modemGroup(), MODEMNAME_KEY, n); |
380 | // return true; //FIXME | 380 | // return true; //FIXME |
381 | // } | 381 | // } |
382 | 382 | ||
383 | bool PPPData::setModemDevice(const QString &n) { | 383 | bool PPPData::setModemDevice(const QString &n) { |
384 | odebug << "Setting modem dev to >" << n.latin1() << "<" << oendl; | 384 | odebug << "Setting modem dev to >" << n.latin1() << "<" << oendl; |
385 | writeConfig(modemGroup(), MODEMDEV_KEY, n); | 385 | writeConfig(modemGroup(), MODEMDEV_KEY, n); |
386 | return true; //FIXME | 386 | return true; //FIXME |
387 | } | 387 | } |
388 | 388 | ||
389 | 389 | ||
390 | const QString PPPData::flowcontrol() { | 390 | enum PPPData::FlowControl PPPData::flowcontrol() { |
391 | return readConfig(modemGroup(), FLOWCONTROL_KEY, "CRTSCTS"); | 391 | return static_cast<FlowControl>(readNumConfig(modemGroup(), FLOWCONTROL_KEY, FlowHardware)); |
392 | } | 392 | } |
393 | 393 | ||
394 | 394 | ||
395 | void PPPData::setFlowcontrol(const QString &n) { | 395 | void PPPData::setFlowcontrol(enum FlowControl n) { |
396 | writeConfig(modemGroup(), FLOWCONTROL_KEY, n); | 396 | writeConfig(modemGroup(), FLOWCONTROL_KEY, n); |
397 | } | 397 | } |
398 | 398 | ||
399 | 399 | ||
400 | const QString PPPData::speed() { | 400 | const QString PPPData::speed() { |
401 | QString s = readConfig(modemGroup(), SPEED_KEY, "57600"); | 401 | QString s = readConfig(modemGroup(), SPEED_KEY, "57600"); |
402 | // undo the damage of a bug in former versions. It left an empty Speed= | 402 | // undo the damage of a bug in former versions. It left an empty Speed= |
403 | // entry in kppprc. kppp did set the serial port to 57600 as default but | 403 | // entry in kppprc. kppp did set the serial port to 57600 as default but |
404 | // pppd wouldn't receive the speed via the command line. | 404 | // pppd wouldn't receive the speed via the command line. |
405 | if(s.toUInt() == 0) | 405 | if(s.toUInt() == 0) |
406 | s = "57600"; | 406 | s = "57600"; |
407 | return s; | 407 | return s; |
408 | } | 408 | } |
409 | 409 | ||
410 | 410 | ||
411 | void PPPData::setSpeed(const QString &n) { | 411 | void PPPData::setSpeed(const QString &n) { |
412 | writeConfig(modemGroup(), SPEED_KEY, n); | 412 | writeConfig(modemGroup(), SPEED_KEY, n); |
413 | } | 413 | } |
414 | 414 | ||
415 | 415 | ||
416 | #if 0 | 416 | #if 0 |
417 | void PPPData::setUseCDLine(const int n) { | 417 | void PPPData::setUseCDLine(const int n) { |
418 | writeConfig(modemGroup(),USECDLINE_KEY,n); | 418 | writeConfig(modemGroup(),USECDLINE_KEY,n); |
419 | } | 419 | } |
420 | 420 | ||
421 | 421 | ||
422 | int PPPData::UseCDLine() { | 422 | int PPPData::UseCDLine() { |
423 | return readNumConfig(modemGroup(),USECDLINE_KEY,0); | 423 | return readNumConfig(modemGroup(),USECDLINE_KEY,0); |
424 | } | 424 | } |
425 | #endif | 425 | #endif |
426 | 426 | ||
427 | const QString PPPData::modemEscapeStr() { | 427 | const QString PPPData::modemEscapeStr() { |
428 | return readConfig(modemGroup(),ESCAPESTR_KEY,"+++"); | 428 | return readConfig(modemGroup(),ESCAPESTR_KEY,"+++"); |
429 | } | 429 | } |
430 | 430 | ||
431 | 431 | ||
432 | void PPPData::setModemEscapeStr(const QString &n) { | 432 | void PPPData::setModemEscapeStr(const QString &n) { |
433 | writeConfig(modemGroup(),ESCAPESTR_KEY,n); | 433 | writeConfig(modemGroup(),ESCAPESTR_KEY,n); |
434 | } | 434 | } |
435 | 435 | ||
436 | 436 | ||
437 | const QString PPPData::modemEscapeResp() { | 437 | const QString PPPData::modemEscapeResp() { |
438 | return readConfig(modemGroup(),ESCAPERESP_KEY,"OK"); | 438 | return readConfig(modemGroup(),ESCAPERESP_KEY,"OK"); |
439 | } | 439 | } |
440 | 440 | ||
441 | 441 | ||
442 | void PPPData::setModemEscapeResp(const QString &n) { | 442 | void PPPData::setModemEscapeResp(const QString &n) { |
443 | writeConfig(modemGroup(),ESCAPERESP_KEY,n); | 443 | writeConfig(modemGroup(),ESCAPERESP_KEY,n); |
444 | } | 444 | } |
445 | 445 | ||
446 | 446 | ||
447 | int PPPData::modemEscapeGuardTime() { | 447 | int PPPData::modemEscapeGuardTime() { |
448 | return readNumConfig(modemGroup(),ESCAPEGUARDTIME_KEY,50); | 448 | return readNumConfig(modemGroup(),ESCAPEGUARDTIME_KEY,50); |
449 | } | 449 | } |
450 | 450 | ||
451 | 451 | ||
452 | void PPPData::setModemEscapeGuardTime(int n) { | 452 | void PPPData::setModemEscapeGuardTime(int n) { |
453 | writeConfig(modemGroup(),ESCAPEGUARDTIME_KEY,n); | 453 | writeConfig(modemGroup(),ESCAPEGUARDTIME_KEY,n); |
454 | } | 454 | } |
455 | 455 | ||
456 | 456 | ||
457 | bool PPPData::modemLockFile() { | 457 | bool PPPData::modemLockFile() { |
458 | return readNumConfig(modemGroup(), LOCKFILE_KEY, 1); | 458 | return readNumConfig(modemGroup(), LOCKFILE_KEY, 1); |
459 | } | 459 | } |
460 | 460 | ||
461 | 461 | ||
462 | void PPPData::setModemLockFile(bool set) { | 462 | void PPPData::setModemLockFile(bool set) { |
463 | writeConfig(modemGroup(), LOCKFILE_KEY, set); | 463 | writeConfig(modemGroup(), LOCKFILE_KEY, set); |
464 | } | 464 | } |
465 | 465 | ||
466 | 466 | ||
467 | int PPPData::modemTimeout() { | 467 | int PPPData::modemTimeout() { |
468 | return readNumConfig(modemGroup(), TIMEOUT_KEY, MODEM_TIMEOUT); | 468 | return readNumConfig(modemGroup(), TIMEOUT_KEY, MODEM_TIMEOUT); |
469 | } | 469 | } |
470 | 470 | ||
471 | 471 | ||
472 | void PPPData::setModemTimeout(int n) { | 472 | void PPPData::setModemTimeout(int n) { |
473 | writeConfig(modemGroup(), TIMEOUT_KEY, n); | 473 | writeConfig(modemGroup(), TIMEOUT_KEY, n); |
474 | } | 474 | } |
475 | 475 | ||
476 | 476 | ||
477 | int PPPData::modemToneDuration() { | 477 | int PPPData::modemToneDuration() { |
478 | return readNumConfig(modemGroup(), TONEDURATION_KEY,MODEM_TONEDURATION); | 478 | return readNumConfig(modemGroup(), TONEDURATION_KEY,MODEM_TONEDURATION); |
479 | } | 479 | } |
480 | 480 | ||
481 | 481 | ||
482 | void PPPData::setModemToneDuration(int n) { | 482 | void PPPData::setModemToneDuration(int n) { |
483 | writeConfig(modemGroup(), TONEDURATION_KEY, n); | 483 | writeConfig(modemGroup(), TONEDURATION_KEY, n); |
484 | } | 484 | } |
485 | 485 | ||
486 | 486 | ||
487 | int PPPData::busyWait() { | 487 | int PPPData::busyWait() { |
488 | return readNumConfig(modemGroup(), BUSYWAIT_KEY, BUSY_WAIT); | 488 | return readNumConfig(modemGroup(), BUSYWAIT_KEY, BUSY_WAIT); |
489 | } | 489 | } |
490 | 490 | ||
491 | 491 | ||
@@ -627,198 +627,198 @@ const QString PPPData::modemAnswerStr() { | |||
627 | QString PPPData::volumeOff() { | 627 | QString PPPData::volumeOff() { |
628 | return readConfig(modemGroup(), VOLUME_OFF, "M0L0"); | 628 | return readConfig(modemGroup(), VOLUME_OFF, "M0L0"); |
629 | } | 629 | } |
630 | 630 | ||
631 | 631 | ||
632 | void PPPData::setVolumeOff(const QString &s) { | 632 | void PPPData::setVolumeOff(const QString &s) { |
633 | writeConfig(modemGroup(), VOLUME_OFF, s); | 633 | writeConfig(modemGroup(), VOLUME_OFF, s); |
634 | } | 634 | } |
635 | 635 | ||
636 | 636 | ||
637 | QString PPPData::volumeMedium() { | 637 | QString PPPData::volumeMedium() { |
638 | return readConfig(modemGroup(), VOLUME_MEDIUM, "M1L1"); | 638 | return readConfig(modemGroup(), VOLUME_MEDIUM, "M1L1"); |
639 | } | 639 | } |
640 | 640 | ||
641 | 641 | ||
642 | void PPPData::setVolumeMedium(const QString &s) { | 642 | void PPPData::setVolumeMedium(const QString &s) { |
643 | writeConfig(modemGroup(), VOLUME_MEDIUM, s); | 643 | writeConfig(modemGroup(), VOLUME_MEDIUM, s); |
644 | } | 644 | } |
645 | 645 | ||
646 | 646 | ||
647 | QString PPPData::volumeHigh() { | 647 | QString PPPData::volumeHigh() { |
648 | QString tmp = readConfig(modemGroup(), VOLUME_HIGH, "M1L3"); | 648 | QString tmp = readConfig(modemGroup(), VOLUME_HIGH, "M1L3"); |
649 | if(tmp == "M1L4") | 649 | if(tmp == "M1L4") |
650 | tmp = "M1L3"; | 650 | tmp = "M1L3"; |
651 | return tmp; | 651 | return tmp; |
652 | } | 652 | } |
653 | 653 | ||
654 | 654 | ||
655 | void PPPData::setVolumeHigh(const QString &s) { | 655 | void PPPData::setVolumeHigh(const QString &s) { |
656 | writeConfig(modemGroup(), VOLUME_HIGH, s); | 656 | writeConfig(modemGroup(), VOLUME_HIGH, s); |
657 | } | 657 | } |
658 | 658 | ||
659 | 659 | ||
660 | QString PPPData::volumeInitString() { | 660 | QString PPPData::volumeInitString() { |
661 | QString s; | 661 | QString s; |
662 | 662 | ||
663 | switch(volume()) { | 663 | switch(volume()) { |
664 | case 0: | 664 | case 0: |
665 | s = volumeOff(); | 665 | s = volumeOff(); |
666 | break; | 666 | break; |
667 | case 1: | 667 | case 1: |
668 | s = volumeMedium(); | 668 | s = volumeMedium(); |
669 | break; | 669 | break; |
670 | case 2: | 670 | case 2: |
671 | s = volumeHigh(); | 671 | s = volumeHigh(); |
672 | break; | 672 | break; |
673 | default: | 673 | default: |
674 | s = volumeMedium(); | 674 | s = volumeMedium(); |
675 | } | 675 | } |
676 | 676 | ||
677 | return s; | 677 | return s; |
678 | } | 678 | } |
679 | 679 | ||
680 | 680 | ||
681 | int PPPData::volume() { | 681 | int PPPData::volume() { |
682 | return readNumConfig(modemGroup(), VOLUME_KEY, 1); | 682 | return readNumConfig(modemGroup(), VOLUME_KEY, 1); |
683 | } | 683 | } |
684 | 684 | ||
685 | 685 | ||
686 | void PPPData::setVolume(int i) { | 686 | void PPPData::setVolume(int i) { |
687 | writeConfig(modemGroup(), VOLUME_KEY, i); | 687 | writeConfig(modemGroup(), VOLUME_KEY, i); |
688 | } | 688 | } |
689 | 689 | ||
690 | int PPPData::waitForDialTone() { | 690 | int PPPData::waitForDialTone() { |
691 | return readNumConfig(modemGroup(), DIALTONEWAIT_KEY, 1); | 691 | return readNumConfig(modemGroup(), DIALTONEWAIT_KEY, 1); |
692 | } | 692 | } |
693 | 693 | ||
694 | void PPPData::setWaitForDialTone(int i) { | 694 | void PPPData::setWaitForDialTone(int i) { |
695 | writeConfig(modemGroup(), DIALTONEWAIT_KEY, i); | 695 | writeConfig(modemGroup(), DIALTONEWAIT_KEY, i); |
696 | } | 696 | } |
697 | 697 | ||
698 | void PPPData::setModemAnswerStr(const QString &n) { | 698 | void PPPData::setModemAnswerStr(const QString &n) { |
699 | writeConfig(modemGroup(), ANSWERSTR_KEY, n); | 699 | writeConfig(modemGroup(), ANSWERSTR_KEY, n); |
700 | } | 700 | } |
701 | 701 | ||
702 | 702 | ||
703 | const QString PPPData::modemRingResp() { | 703 | const QString PPPData::modemRingResp() { |
704 | return readConfig(modemGroup(), RINGRESP_KEY, "RING"); | 704 | return readConfig(modemGroup(), RINGRESP_KEY, "RING"); |
705 | } | 705 | } |
706 | 706 | ||
707 | 707 | ||
708 | void PPPData::setModemRingResp(const QString &n) { | 708 | void PPPData::setModemRingResp(const QString &n) { |
709 | writeConfig(modemGroup(), RINGRESP_KEY, n); | 709 | writeConfig(modemGroup(), RINGRESP_KEY, n); |
710 | } | 710 | } |
711 | 711 | ||
712 | 712 | ||
713 | const QString PPPData::modemAnswerResp() { | 713 | const QString PPPData::modemAnswerResp() { |
714 | return readConfig(modemGroup(), ANSWERRESP_KEY, "CONNECT"); | 714 | return readConfig(modemGroup(), ANSWERRESP_KEY, "CONNECT"); |
715 | } | 715 | } |
716 | 716 | ||
717 | 717 | ||
718 | void PPPData::setModemAnswerResp(const QString &n) { | 718 | void PPPData::setModemAnswerResp(const QString &n) { |
719 | writeConfig(modemGroup(), ANSWERRESP_KEY, n); | 719 | writeConfig(modemGroup(), ANSWERRESP_KEY, n); |
720 | } | 720 | } |
721 | 721 | ||
722 | 722 | ||
723 | const QString PPPData::enter() { | 723 | enum PPPData::LineTermination PPPData::enter(){ |
724 | return readConfig(modemGroup(), ENTER_KEY, "CR"); | 724 | return static_cast<PPPData::LineTermination>(readNumConfig(modemGroup(), ENTER_KEY, EndCR)); |
725 | } | 725 | } |
726 | 726 | ||
727 | 727 | ||
728 | void PPPData::setEnter(const QString &n) { | 728 | void PPPData::setEnter(enum PPPData::LineTermination n) { |
729 | writeConfig(modemGroup(), ENTER_KEY, n); | 729 | writeConfig(modemGroup(), ENTER_KEY, n); |
730 | } | 730 | } |
731 | 731 | ||
732 | 732 | ||
733 | // | 733 | // |
734 | // functions to set/return account information | 734 | // functions to set/return account information |
735 | // | 735 | // |
736 | 736 | ||
737 | //returns number of accounts | 737 | //returns number of accounts |
738 | int PPPData::count() const { | 738 | int PPPData::count() const { |
739 | return highcount + 1; | 739 | return highcount + 1; |
740 | } | 740 | } |
741 | 741 | ||
742 | 742 | ||
743 | bool PPPData::setAccount(const QString &aname) { | 743 | bool PPPData::setAccount(const QString &aname) { |
744 | odebug << "setting account to >" << aname.latin1() << "<" << oendl; | 744 | odebug << "setting account to >" << aname.latin1() << "<" << oendl; |
745 | for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) { | 745 | for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) { |
746 | cgroup = *it; | 746 | cgroup = *it; |
747 | odebug << "PPPData::setAccount " << cgroup.latin1() << "" << oendl; | 747 | odebug << "PPPData::setAccount " << cgroup.latin1() << "" << oendl; |
748 | odebug << "iterator " << (*it).latin1() << "" << oendl; | 748 | odebug << "iterator " << (*it).latin1() << "" << oendl; |
749 | if(accname() == aname) { | 749 | if(accname() == aname) { |
750 | odebug << "SUCCESS" << oendl; | 750 | odebug << "SUCCESS" << oendl; |
751 | return true; | 751 | return true; |
752 | } | 752 | } |
753 | 753 | ||
754 | } | 754 | } |
755 | odebug << "FAILURE" << oendl; | 755 | odebug << "FAILURE" << oendl; |
756 | return false; | 756 | return false; |
757 | } | 757 | } |
758 | 758 | ||
759 | /* | 759 | /* |
760 | bool PPPData::setAccountbyIndex(int i) { | 760 | bool PPPData::setAccountbyIndex(int i) { |
761 | if(i >= 0 && i <= highcount) { | 761 | if(i >= 0 && i <= highcount) { |
762 | QString tmp; | 762 | QString tmp; |
763 | tmp.sprintf("%s%i", ACCOUNT_GRP, i); | 763 | tmp.sprintf("%s%i", ACCOUNT_GRP, i); |
764 | if (_deleted.find(tmp)!=_deleted.end()) return false; | 764 | if (_deleted.find(tmp)!=_deleted.end()) return false; |
765 | caccount = i; | 765 | caccount = i; |
766 | cgroup = tmp; | 766 | cgroup = tmp; |
767 | return true; | 767 | return true; |
768 | } | 768 | } |
769 | return false; | 769 | return false; |
770 | } | 770 | } |
771 | */ | 771 | */ |
772 | 772 | ||
773 | bool PPPData::isUniqueAccname(const QString &n) { | 773 | bool PPPData::isUniqueAccname(const QString &n) { |
774 | QString save_cgroup = cgroup; | 774 | QString save_cgroup = cgroup; |
775 | for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) { | 775 | for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) { |
776 | cgroup = *it; | 776 | cgroup = *it; |
777 | odebug << "PPPData::setAccount " << cgroup.latin1() << "" << oendl; | 777 | odebug << "PPPData::setAccount " << cgroup.latin1() << "" << oendl; |
778 | odebug << "" << (*it).latin1() << " \n" << oendl; | 778 | odebug << "" << (*it).latin1() << " \n" << oendl; |
779 | if(accname() == n && cgroup != save_cgroup) { | 779 | if(accname() == n && cgroup != save_cgroup) { |
780 | cgroup = save_cgroup; | 780 | cgroup = save_cgroup; |
781 | odebug << "SUCCESS" << oendl; | 781 | odebug << "SUCCESS" << oendl; |
782 | return false; | 782 | return false; |
783 | } | 783 | } |
784 | 784 | ||
785 | } | 785 | } |
786 | cgroup = save_cgroup; | 786 | cgroup = save_cgroup; |
787 | return true; | 787 | return true; |
788 | } | 788 | } |
789 | 789 | ||
790 | 790 | ||
791 | bool PPPData::isUniqueDevname(const QString &n) { | 791 | bool PPPData::isUniqueDevname(const QString &n) { |
792 | QString save_mName = _modemName; | 792 | QString save_mName = _modemName; |
793 | odebug << "PPPData::isUniqueDevname checking if " << n.latin1() << " is unique" << oendl; | 793 | odebug << "PPPData::isUniqueDevname checking if " << n.latin1() << " is unique" << oendl; |
794 | for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) { | 794 | for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) { |
795 | _modemName = *it; | 795 | _modemName = *it; |
796 | odebug << "PPPData::isUniqueDevname " << n.latin1() << " == " << devname().latin1() << "" << oendl; | 796 | odebug << "PPPData::isUniqueDevname " << n.latin1() << " == " << devname().latin1() << "" << oendl; |
797 | if(devname() == n && _modemName != save_mName) { | 797 | if(devname() == n && _modemName != save_mName) { |
798 | _modemName = save_mName; | 798 | _modemName = save_mName; |
799 | odebug << "NOT UNIQUE" << oendl; | 799 | odebug << "NOT UNIQUE" << oendl; |
800 | return false; | 800 | return false; |
801 | } | 801 | } |
802 | 802 | ||
803 | } | 803 | } |
804 | _modemName = save_mName; | 804 | _modemName = save_mName; |
805 | return true; | 805 | return true; |
806 | } | 806 | } |
807 | 807 | ||
808 | 808 | ||
809 | bool PPPData::deleteAccount() { | 809 | bool PPPData::deleteAccount() { |
810 | // FIXME: check if this account exists in a config... | 810 | // FIXME: check if this account exists in a config... |
811 | Config cfg = PPPData::config(); | 811 | Config cfg = PPPData::config(); |
812 | cfg.setGroup(cgroup); | 812 | cfg.setGroup(cgroup); |
813 | cfg.clearGroup(); | 813 | cfg.clearGroup(); |
814 | accountList.remove(cgroup); | 814 | accountList.remove(cgroup); |
815 | 815 | ||
816 | QString key; | 816 | QString key; |
817 | QStringList keys; | 817 | QStringList keys; |
818 | for( QMap<QString,QString>::Iterator it = stringEntries.begin(); | 818 | for( QMap<QString,QString>::Iterator it = stringEntries.begin(); |
819 | it != stringEntries.end(); ++it ){ | 819 | it != stringEntries.end(); ++it ){ |
820 | QString val = it.data(); | 820 | QString val = it.data(); |
821 | key = it.key(); | 821 | key = it.key(); |
822 | keys = QStringList::split( "SEPARATOR", key ); | 822 | keys = QStringList::split( "SEPARATOR", key ); |
823 | if(keys[0]==cgroup){ | 823 | if(keys[0]==cgroup){ |
824 | stringEntries.remove( it ); | 824 | stringEntries.remove( it ); |
diff --git a/noncore/settings/networksettings/ppp/pppdata.h b/noncore/settings/networksettings/ppp/pppdata.h index d1cbeb5..d731b62 100644 --- a/noncore/settings/networksettings/ppp/pppdata.h +++ b/noncore/settings/networksettings/ppp/pppdata.h | |||
@@ -72,282 +72,293 @@ class Config; | |||
72 | #define SHOWCLOCK_KEY "ShowClock" | 72 | #define SHOWCLOCK_KEY "ShowClock" |
73 | #define SHOWLOGWIN_KEY "ShowLogWindow" | 73 | #define SHOWLOGWIN_KEY "ShowLogWindow" |
74 | #define AUTOREDIAL_KEY "AutomaticRedial" | 74 | #define AUTOREDIAL_KEY "AutomaticRedial" |
75 | #define DISCONNECT_KEY "DisconnectOnXServerExit" | 75 | #define DISCONNECT_KEY "DisconnectOnXServerExit" |
76 | #define QUITONDISCONNECT_KEY "QuitOnDisconnect" | 76 | #define QUITONDISCONNECT_KEY "QuitOnDisconnect" |
77 | #define NUMACCOUNTS_KEY "HighcountAccounts" | 77 | #define NUMACCOUNTS_KEY "HighcountAccounts" |
78 | #define NUMDEVICES_KEY "HighcountDevices" | 78 | #define NUMDEVICES_KEY "HighcountDevices" |
79 | #define ID_KEY "ID" | 79 | #define ID_KEY "ID" |
80 | 80 | ||
81 | // modem | 81 | // modem |
82 | #define MODEMNAME_KEY "Modem_Name" | 82 | #define MODEMNAME_KEY "Modem_Name" |
83 | #define MODEMDEV_KEY "Device" | 83 | #define MODEMDEV_KEY "Device" |
84 | #define LOCKFILE_KEY "UseLockFile" | 84 | #define LOCKFILE_KEY "UseLockFile" |
85 | #define FLOWCONTROL_KEY "FlowControl" | 85 | #define FLOWCONTROL_KEY "FlowControl" |
86 | #define SPEED_KEY "Speed" | 86 | #define SPEED_KEY "Speed" |
87 | #define TIMEOUT_KEY "Timeout" | 87 | #define TIMEOUT_KEY "Timeout" |
88 | #define TONEDURATION_KEY "ToneDuration" | 88 | #define TONEDURATION_KEY "ToneDuration" |
89 | #define BUSYWAIT_KEY "BusyWait" | 89 | #define BUSYWAIT_KEY "BusyWait" |
90 | #define INITSTR_KEY "InitString" | 90 | #define INITSTR_KEY "InitString" |
91 | #define INITRESP_KEY "InitResponse" | 91 | #define INITRESP_KEY "InitResponse" |
92 | #define PREINITDELAY_KEY "PreInitDelay" | 92 | #define PREINITDELAY_KEY "PreInitDelay" |
93 | #define INITDELAY_KEY "InitDelay" | 93 | #define INITDELAY_KEY "InitDelay" |
94 | #define NODTDETECT_KEY "NoDialToneDetection" | 94 | #define NODTDETECT_KEY "NoDialToneDetection" |
95 | #define DIALTONEWAIT_KEY "WaitForDialTone" | 95 | #define DIALTONEWAIT_KEY "WaitForDialTone" |
96 | #define DIALSTR_KEY "DialString" | 96 | #define DIALSTR_KEY "DialString" |
97 | #define CONNECTRESP_KEY "ConnectResponse" | 97 | #define CONNECTRESP_KEY "ConnectResponse" |
98 | #define BUSYRESP_KEY "BusyResponse" | 98 | #define BUSYRESP_KEY "BusyResponse" |
99 | #define NOCARRIERRESP_KEY "NoCarrierResponse" | 99 | #define NOCARRIERRESP_KEY "NoCarrierResponse" |
100 | #define NODIALTONERESP_KEY "NoDialToneResp" | 100 | #define NODIALTONERESP_KEY "NoDialToneResp" |
101 | #define HANGUPSTR_KEY "HangupString" | 101 | #define HANGUPSTR_KEY "HangupString" |
102 | #define HANGUPRESP_KEY "HangUpResponse" | 102 | #define HANGUPRESP_KEY "HangUpResponse" |
103 | #define ANSWERSTR_KEY "AnswerString" | 103 | #define ANSWERSTR_KEY "AnswerString" |
104 | #define RINGRESP_KEY "RingResponse" | 104 | #define RINGRESP_KEY "RingResponse" |
105 | #define ANSWERRESP_KEY "AnswerResponse" | 105 | #define ANSWERRESP_KEY "AnswerResponse" |
106 | #define ENTER_KEY "Enter" | 106 | #define ENTER_KEY "Enter" |
107 | #define ESCAPESTR_KEY "EscapeString" | 107 | #define ESCAPESTR_KEY "EscapeString" |
108 | #define ESCAPERESP_KEY "EscapeResponse" | 108 | #define ESCAPERESP_KEY "EscapeResponse" |
109 | #define ESCAPEGUARDTIME_KEY "EscapeGuardTime" | 109 | #define ESCAPEGUARDTIME_KEY "EscapeGuardTime" |
110 | #define USECDLINE_KEY "UseCDLine" | 110 | #define USECDLINE_KEY "UseCDLine" |
111 | #define VOLUME_HIGH "VolumeHigh" | 111 | #define VOLUME_HIGH "VolumeHigh" |
112 | #define VOLUME_MEDIUM "VolumeMedium" | 112 | #define VOLUME_MEDIUM "VolumeMedium" |
113 | #define VOLUME_OFF "VolumeOff" | 113 | #define VOLUME_OFF "VolumeOff" |
114 | #define VOLUME_KEY "Volume" | 114 | #define VOLUME_KEY "Volume" |
115 | 115 | ||
116 | // account | 116 | // account |
117 | #define NAME_KEY "Name" | 117 | #define NAME_KEY "Name" |
118 | #define PHONENUMBER_KEY "Phonenumber" | 118 | #define PHONENUMBER_KEY "Phonenumber" |
119 | #define DIAL_PREFIX_KEY "DialPrefix" | 119 | #define DIAL_PREFIX_KEY "DialPrefix" |
120 | #define AUTH_KEY "Authentication" | 120 | #define AUTH_KEY "Authentication" |
121 | #define STORED_PASSWORD_KEY "Password" | 121 | #define STORED_PASSWORD_KEY "Password" |
122 | #define STORED_USERNAME_KEY "Username" | 122 | #define STORED_USERNAME_KEY "Username" |
123 | #define STORE_PASSWORD_KEY "StorePassword" | 123 | #define STORE_PASSWORD_KEY "StorePassword" |
124 | #define BEFORE_CONNECT_KEY "BeforeConnect" | 124 | #define BEFORE_CONNECT_KEY "BeforeConnect" |
125 | #define COMMAND_KEY "Command" | 125 | #define COMMAND_KEY "Command" |
126 | #define DISCONNECT_COMMAND_KEY "DisconnectCommand" | 126 | #define DISCONNECT_COMMAND_KEY "DisconnectCommand" |
127 | #define BEFORE_DISCONNECT_KEY "BeforeDisconnect" | 127 | #define BEFORE_DISCONNECT_KEY "BeforeDisconnect" |
128 | #define IPADDR_KEY "IPAddr" | 128 | #define IPADDR_KEY "IPAddr" |
129 | #define SUBNETMASK_KEY "SubnetMask" | 129 | #define SUBNETMASK_KEY "SubnetMask" |
130 | #define ACCTENABLED_KEY "AccountingEnabled" | 130 | #define ACCTENABLED_KEY "AccountingEnabled" |
131 | #define VOLACCTENABLED_KEY "VolumeAccountingEnabled" | 131 | #define VOLACCTENABLED_KEY "VolumeAccountingEnabled" |
132 | #define ACCTFILE_KEY "AccountingFile" | 132 | #define ACCTFILE_KEY "AccountingFile" |
133 | #define AUTONAME_KEY "AutoName" | 133 | #define AUTONAME_KEY "AutoName" |
134 | #define GATEWAY_KEY "Gateway" | 134 | #define GATEWAY_KEY "Gateway" |
135 | #define DEFAULTROUTE_KEY "DefaultRoute" | 135 | #define DEFAULTROUTE_KEY "DefaultRoute" |
136 | #define DOMAIN_KEY "Domain" | 136 | #define DOMAIN_KEY "Domain" |
137 | #define DNS_KEY "DNS" | 137 | #define DNS_KEY "DNS" |
138 | #define AUTODNS_KEY "AutoDNS" | 138 | #define AUTODNS_KEY "AutoDNS" |
139 | #define EXDNSDISABLED_KEY "ExDNSDisabled" | 139 | #define EXDNSDISABLED_KEY "ExDNSDisabled" |
140 | #define SCRIPTCOM_KEY "ScriptCommands" | 140 | #define SCRIPTCOM_KEY "ScriptCommands" |
141 | #define SCRIPTARG_KEY "ScriptArguments" | 141 | #define SCRIPTARG_KEY "ScriptArguments" |
142 | #define PPPDARG_KEY "pppdArguments" | 142 | #define PPPDARG_KEY "pppdArguments" |
143 | #define PPP_DEBUG_OPTION "PPPDebug" | 143 | #define PPP_DEBUG_OPTION "PPPDebug" |
144 | #define ICONIFY_ON_CONNECT_KEY "iconifyOnConnect" | 144 | #define ICONIFY_ON_CONNECT_KEY "iconifyOnConnect" |
145 | #define DOCKING_KEY "DockIntoPanel" | 145 | #define DOCKING_KEY "DockIntoPanel" |
146 | #define TOTALCOSTS_KEY "TotalCosts" | 146 | #define TOTALCOSTS_KEY "TotalCosts" |
147 | #define TOTALBYTES_KEY "TotalBytes" | 147 | #define TOTALBYTES_KEY "TotalBytes" |
148 | 148 | ||
149 | // pppd errors | 149 | // pppd errors |
150 | #define E_IF_TIMEOUT 1 | 150 | #define E_IF_TIMEOUT 1 |
151 | #define E_PPPD_DIED 2 | 151 | #define E_PPPD_DIED 2 |
152 | 152 | ||
153 | // account list | 153 | // account list |
154 | #define ACCOUNTS_COUNT "Accounts_Count" | 154 | #define ACCOUNTS_COUNT "Accounts_Count" |
155 | #define ACOUNTS_DEV "Accounts_Modem" | 155 | #define ACOUNTS_DEV "Accounts_Modem" |
156 | #define ACOUNTS_ACC "Accounts_Account" | 156 | #define ACOUNTS_ACC "Accounts_Account" |
157 | 157 | ||
158 | #define DEVICESNAMES_LIST "DevicesNames_List" | 158 | #define DEVICESNAMES_LIST "DevicesNames_List" |
159 | #define DEVICES_LIST "Devices_List" | 159 | #define DEVICES_LIST "Devices_List" |
160 | #define DEVICES_LIST_SEP ',' | 160 | #define DEVICES_LIST_SEP ',' |
161 | 161 | ||
162 | class PPPData { | 162 | class PPPData { |
163 | public: | 163 | public: |
164 | PPPData(); | 164 | PPPData(); |
165 | ~PPPData() {}; | 165 | ~PPPData() {}; |
166 | 166 | ||
167 | enum { NumInitStrings = 2 }; | 167 | enum { NumInitStrings = 2 }; |
168 | enum LineTermination { | ||
169 | EndCR, | ||
170 | EndLF, | ||
171 | EndCRLF | ||
172 | }; | ||
173 | |||
174 | enum FlowControl { | ||
175 | FlowHardware, | ||
176 | FlowSoftware, | ||
177 | FlowNone | ||
178 | }; | ||
168 | 179 | ||
169 | // general functions | 180 | // general functions |
170 | void save(); | 181 | void save(); |
171 | void cancel(); | 182 | void cancel(); |
172 | 183 | ||
173 | QStringList getAccountList(); | 184 | QStringList getAccountList(); |
174 | 185 | ||
175 | static QMap<QString,QString> getConfiguredInterfaces(); | 186 | static QMap<QString,QString> getConfiguredInterfaces(); |
176 | static void setConfiguredInterfaces( QMap<QString,QString> ); | 187 | static void setConfiguredInterfaces( QMap<QString,QString> ); |
177 | 188 | ||
178 | // function to read/write date to configuration file | 189 | // function to read/write date to configuration file |
179 | static Config config(); | 190 | static Config config(); |
180 | QString readConfig(const QString &, const QString &, const QString &); | 191 | QString readConfig(const QString &, const QString &, const QString &); |
181 | int readNumConfig(const QString &, const QString &, int); | 192 | int readNumConfig(const QString &, const QString &, int); |
182 | bool readListConfig(const QString &, const QString &, | 193 | bool readListConfig(const QString &, const QString &, |
183 | QStringList &, char sep = ','); | 194 | QStringList &, char sep = ','); |
184 | void writeConfig(const QString &, const QString &, const QString &); | 195 | void writeConfig(const QString &, const QString &, const QString &); |
185 | void writeConfig(const QString &, const QString &, int); | 196 | void writeConfig(const QString &, const QString &, int); |
186 | void writeListConfig(const QString &, const QString &, | 197 | void writeListConfig(const QString &, const QString &, |
187 | QStringList &, char sep = ','); | 198 | QStringList &, char sep = ','); |
188 | 199 | ||
189 | // return the current account group | 200 | // return the current account group |
190 | QString currentGroup() { return cgroup; } | 201 | QString currentGroup() { return cgroup; } |
191 | QString modemGroup(); | 202 | QString modemGroup(); |
192 | 203 | ||
193 | // functions to set/get general kppp info | 204 | // functions to set/get general kppp info |
194 | QString password(); | 205 | QString password(); |
195 | void setPassword(const QString &); | 206 | void setPassword(const QString &); |
196 | 207 | ||
197 | // int currentAccountID() { return caccount; }; | 208 | // int currentAccountID() { return caccount; }; |
198 | const QString defaultAccount(); | 209 | const QString defaultAccount(); |
199 | void setDefaultAccount(const QString &); | 210 | void setDefaultAccount(const QString &); |
200 | 211 | ||
201 | void set_xserver_exit_disconnect(bool set); | 212 | void set_xserver_exit_disconnect(bool set); |
202 | bool get_xserver_exit_disconnect(); | 213 | bool get_xserver_exit_disconnect(); |
203 | 214 | ||
204 | void setPPPDebug(bool set); | 215 | void setPPPDebug(bool set); |
205 | bool getPPPDebug(); | 216 | bool getPPPDebug(); |
206 | 217 | ||
207 | void set_quit_on_disconnect(bool); | 218 | void set_quit_on_disconnect(bool); |
208 | bool quit_on_disconnect(); | 219 | bool quit_on_disconnect(); |
209 | 220 | ||
210 | void set_show_clock_on_caption(bool set); | 221 | void set_show_clock_on_caption(bool set); |
211 | bool get_show_clock_on_caption(); | 222 | bool get_show_clock_on_caption(); |
212 | 223 | ||
213 | void set_show_log_window(bool set); | 224 | void set_show_log_window(bool set); |
214 | bool get_show_log_window(); | 225 | bool get_show_log_window(); |
215 | 226 | ||
216 | void set_automatic_redial(bool set); | 227 | void set_automatic_redial(bool set); |
217 | bool automatic_redial(); | 228 | bool automatic_redial(); |
218 | 229 | ||
219 | // void set_iconify_on_connect(bool set); | 230 | // void set_iconify_on_connect(bool set); |
220 | // bool get_iconify_on_connect(); | 231 | // bool get_iconify_on_connect(); |
221 | 232 | ||
222 | // void set_dock_into_panel(bool set); | 233 | // void set_dock_into_panel(bool set); |
223 | // bool get_dock_into_panel(); | 234 | // bool get_dock_into_panel(); |
224 | 235 | ||
225 | const QString enter(); | 236 | enum LineTermination enter(); |
226 | void setEnter(const QString &); | 237 | void setEnter(enum LineTermination); |
227 | 238 | ||
228 | QString pppdVersion(); | 239 | QString pppdVersion(); |
229 | bool pppdVersionMin(int ver, int mod, int patch); | 240 | bool pppdVersionMin(int ver, int mod, int patch); |
230 | 241 | ||
231 | int pppdTimeout(); | 242 | int pppdTimeout(); |
232 | void setpppdTimeout(int); | 243 | void setpppdTimeout(int); |
233 | 244 | ||
234 | int busyWait(); | 245 | int busyWait(); |
235 | void setbusyWait(int); | 246 | void setbusyWait(int); |
236 | 247 | ||
237 | bool modemLockFile(); | 248 | bool modemLockFile(); |
238 | void setModemLockFile(bool set); | 249 | void setModemLockFile(bool set); |
239 | 250 | ||
240 | int modemEscapeGuardTime(); | 251 | int modemEscapeGuardTime(); |
241 | void setModemEscapeGuardTime(int i); | 252 | void setModemEscapeGuardTime(int i); |
242 | 253 | ||
243 | void setModemEscapeStr(const QString &); | 254 | void setModemEscapeStr(const QString &); |
244 | const QString modemEscapeStr(); | 255 | const QString modemEscapeStr(); |
245 | 256 | ||
246 | void setModemEscapeResp(const QString &); | 257 | void setModemEscapeResp(const QString &); |
247 | const QString modemEscapeResp(); | 258 | const QString modemEscapeResp(); |
248 | 259 | ||
249 | // const QString modemName(); | 260 | // const QString modemName(); |
250 | // bool setModemName(const QString &); | 261 | // bool setModemName(const QString &); |
251 | // bool changeModemName(const QString &); | 262 | // bool changeModemName(const QString &); |
252 | 263 | ||
253 | const QString modemDevice(); | 264 | const QString modemDevice(); |
254 | bool setModemDevice(const QString &); | 265 | bool setModemDevice(const QString &); |
255 | 266 | ||
256 | const QString flowcontrol(); | 267 | enum FlowControl flowcontrol(); |
257 | void setFlowcontrol(const QString &); | 268 | void setFlowcontrol(enum FlowControl); |
258 | 269 | ||
259 | int modemTimeout(); | 270 | int modemTimeout(); |
260 | void setModemTimeout(int); | 271 | void setModemTimeout(int); |
261 | 272 | ||
262 | int modemToneDuration(); | 273 | int modemToneDuration(); |
263 | void setModemToneDuration(int); | 274 | void setModemToneDuration(int); |
264 | 275 | ||
265 | QString volumeInitString(); | 276 | QString volumeInitString(); |
266 | int volume(); | 277 | int volume(); |
267 | void setVolume(int); | 278 | void setVolume(int); |
268 | 279 | ||
269 | int waitForDialTone(); | 280 | int waitForDialTone(); |
270 | void setWaitForDialTone(int i); | 281 | void setWaitForDialTone(int i); |
271 | 282 | ||
272 | // modem command strings/responses | 283 | // modem command strings/responses |
273 | const QString modemInitStr(int i); | 284 | const QString modemInitStr(int i); |
274 | void setModemInitStr(int i, const QString &); | 285 | void setModemInitStr(int i, const QString &); |
275 | 286 | ||
276 | const QString modemInitResp(); | 287 | const QString modemInitResp(); |
277 | void setModemInitResp(const QString &); | 288 | void setModemInitResp(const QString &); |
278 | 289 | ||
279 | int modemPreInitDelay(); | 290 | int modemPreInitDelay(); |
280 | void setModemPreInitDelay(int); | 291 | void setModemPreInitDelay(int); |
281 | 292 | ||
282 | int modemInitDelay(); | 293 | int modemInitDelay(); |
283 | void setModemInitDelay(int); | 294 | void setModemInitDelay(int); |
284 | 295 | ||
285 | QString modemNoDialToneDetectionStr(); | 296 | QString modemNoDialToneDetectionStr(); |
286 | void setModemNoDialToneDetectionStr(const QString &); | 297 | void setModemNoDialToneDetectionStr(const QString &); |
287 | 298 | ||
288 | const QString modemDialStr(); | 299 | const QString modemDialStr(); |
289 | void setModemDialStr(const QString &); | 300 | void setModemDialStr(const QString &); |
290 | 301 | ||
291 | const QString modemConnectResp(); | 302 | const QString modemConnectResp(); |
292 | void setModemConnectResp(const QString &); | 303 | void setModemConnectResp(const QString &); |
293 | 304 | ||
294 | const QString modemBusyResp(); | 305 | const QString modemBusyResp(); |
295 | void setModemBusyResp(const QString &); | 306 | void setModemBusyResp(const QString &); |
296 | 307 | ||
297 | const QString modemNoCarrierResp(); | 308 | const QString modemNoCarrierResp(); |
298 | void setModemNoCarrierResp(const QString &); | 309 | void setModemNoCarrierResp(const QString &); |
299 | 310 | ||
300 | const QString modemNoDialtoneResp(); | 311 | const QString modemNoDialtoneResp(); |
301 | void setModemNoDialtoneResp(const QString &); | 312 | void setModemNoDialtoneResp(const QString &); |
302 | 313 | ||
303 | const QString modemHangupStr(); | 314 | const QString modemHangupStr(); |
304 | void setModemHangupStr(const QString &); | 315 | void setModemHangupStr(const QString &); |
305 | 316 | ||
306 | const QString modemHangupResp(); | 317 | const QString modemHangupResp(); |
307 | void setModemHangupResp(const QString &); | 318 | void setModemHangupResp(const QString &); |
308 | 319 | ||
309 | const QString modemAnswerStr(); | 320 | const QString modemAnswerStr(); |
310 | void setModemAnswerStr(const QString &); | 321 | void setModemAnswerStr(const QString &); |
311 | 322 | ||
312 | const QString modemRingResp(); | 323 | const QString modemRingResp(); |
313 | void setModemRingResp(const QString &); | 324 | void setModemRingResp(const QString &); |
314 | 325 | ||
315 | const QString modemAnswerResp(); | 326 | const QString modemAnswerResp(); |
316 | void setModemAnswerResp(const QString &); | 327 | void setModemAnswerResp(const QString &); |
317 | 328 | ||
318 | QString volumeOff(); | 329 | QString volumeOff(); |
319 | void setVolumeOff(const QString &); | 330 | void setVolumeOff(const QString &); |
320 | 331 | ||
321 | QString volumeMedium(); | 332 | QString volumeMedium(); |
322 | void setVolumeMedium(const QString &); | 333 | void setVolumeMedium(const QString &); |
323 | 334 | ||
324 | QString volumeHigh(); | 335 | QString volumeHigh(); |
325 | void setVolumeHigh(const QString &); | 336 | void setVolumeHigh(const QString &); |
326 | 337 | ||
327 | // functions to set/get account information | 338 | // functions to set/get account information |
328 | int count() const; | 339 | int count() const; |
329 | bool setAccount(const QString &); | 340 | bool setAccount(const QString &); |
330 | // bool setAccountbyIndex(int); | 341 | // bool setAccountbyIndex(int); |
331 | 342 | ||
332 | bool isUniqueAccname(const QString &); | 343 | bool isUniqueAccname(const QString &); |
333 | bool isUniqueDevname(const QString &); | 344 | bool isUniqueDevname(const QString &); |
334 | 345 | ||
335 | bool deleteAccount(); | 346 | bool deleteAccount(); |
336 | bool deleteAccount(const QString &); | 347 | bool deleteAccount(const QString &); |
337 | int newaccount(); | 348 | int newaccount(); |
338 | int copyaccount(const QString&); | 349 | int copyaccount(const QString&); |
339 | 350 | ||
340 | const QString accname(); | 351 | const QString accname(); |
341 | void setAccname(const QString &); | 352 | void setAccname(const QString &); |
342 | 353 | ||
343 | QStringList &phonenumbers(); | 354 | QStringList &phonenumbers(); |
344 | const QString phonenumber(); | 355 | const QString phonenumber(); |
345 | void setPhonenumber(const QString &); | 356 | void setPhonenumber(const QString &); |
346 | 357 | ||
347 | const QString dialPrefix(); | 358 | const QString dialPrefix(); |
348 | void setDialPrefix(const QString &); | 359 | void setDialPrefix(const QString &); |
349 | 360 | ||
350 | int authMethod(); | 361 | int authMethod(); |
351 | void setAuthMethod(int); | 362 | void setAuthMethod(int); |
352 | 363 | ||
353 | const QString storedUsername(); | 364 | const QString storedUsername(); |