author | tille <tille> | 2003-05-24 16:12:02 (UTC) |
---|---|---|
committer | tille <tille> | 2003-05-24 16:12:02 (UTC) |
commit | cc1aa3e178dff65854913bd5667579fc33ce707d (patch) (side-by-side diff) | |
tree | d37d7fd8fb3b9832c0825b015af862f2cc62f473 /noncore/settings/networksettings/ppp/connect.cpp | |
parent | 5667ded1d4583cfb79b2ddfd7aaae0e58ed6d552 (diff) | |
download | opie-cc1aa3e178dff65854913bd5667579fc33ce707d.zip opie-cc1aa3e178dff65854913bd5667579fc33ce707d.tar.gz opie-cc1aa3e178dff65854913bd5667579fc33ce707d.tar.bz2 |
saves config (still in the kppp way)
Diffstat (limited to 'noncore/settings/networksettings/ppp/connect.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/ppp/connect.cpp | 180 |
1 files changed, 90 insertions, 90 deletions
diff --git a/noncore/settings/networksettings/ppp/connect.cpp b/noncore/settings/networksettings/ppp/connect.cpp index b7e229e..a3eda9d 100644 --- a/noncore/settings/networksettings/ppp/connect.cpp +++ b/noncore/settings/networksettings/ppp/connect.cpp @@ -176,13 +176,13 @@ void ConnectWidget::preinit() { messg->setText(i18n("Looking for modem...")); inittimer->start(100); } void ConnectWidget::init() { - gpppdata.setpppdError(0); + PPPData::data()->setpppdError(0); inittimer->stop(); vmain = 0; substate = -1; expecting = false; pausing = false; scriptindex = 0; @@ -193,30 +193,30 @@ void ConnectWidget::init() { firstrunPW = true; // stats->totalbytes = 0; dialnumber = 0; p_kppp->con_speed = ""; -// p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || gpppdata.quit_on_disconnect()); +// p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || PPPData::data()->quit_on_disconnect()); - comlist = &gpppdata.scriptType(); - arglist = &gpppdata.script(); + comlist = &PPPData::data()->scriptType(); + arglist = &PPPData::data()->script(); - QString tit = i18n("Connecting to: %1").arg(gpppdata.accname()); + QString tit = i18n("Connecting to: %1").arg(PPPData::data()->accname()); setCaption(tit); qApp->processEvents(); // run the "before-connect" command - if (!gpppdata.command_before_connect().isEmpty()) { + if (!PPPData::data()->command_before_connect().isEmpty()) { messg->setText(i18n("Running pre-startup command...")); emit debugMessage(i18n("Running pre-startup command...")); qApp->processEvents(); QApplication::flushX(); - pid_t id = execute_command(gpppdata.command_before_connect()); + pid_t id = execute_command(PPPData::data()->command_before_connect()); // int i, status; // do { // qApp->processEvents(); // i = waitpid(id, &status, WNOHANG); // usleep(100000); @@ -247,13 +247,13 @@ void ConnectWidget::init() { semaphore = false; Modem::modem->stop(); Modem::modem->notify(this, SLOT(readChar(unsigned char))); // if we are stuck anywhere we will time out - timeout_timer->start(gpppdata.modemTimeout()*1000); + timeout_timer->start(PPPData::data()->modemTimeout()*1000); // this timer will run the script etc. main_timer_ID = startTimer(10); return; } @@ -281,49 +281,49 @@ void ConnectWidget::timerEvent(QTimerEvent *) { if(substate == -1) { messg->setText(i18n("Initializing modem...")); emit debugMessage(i18n("Initializing modem...")); substate = 0; } - QString initStr = gpppdata.modemInitStr(substate); + QString initStr = PPPData::data()->modemInitStr(substate); if (!initStr.isEmpty()) { // send a carriage return and then wait a bit so that the modem will // let us issue commands. - if(gpppdata.modemPreInitDelay() > 0) { - usleep(gpppdata.modemPreInitDelay() * 5000); + if(PPPData::data()->modemPreInitDelay() > 0) { + usleep(PPPData::data()->modemPreInitDelay() * 5000); writeline(""); - usleep(gpppdata.modemPreInitDelay() * 5000); + usleep(PPPData::data()->modemPreInitDelay() * 5000); } - setExpect(gpppdata.modemInitResp()); + setExpect(PPPData::data()->modemInitResp()); writeline(initStr); - usleep(gpppdata.modemInitDelay() * 10000); // 0.01 - 3.0 sec + usleep(PPPData::data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec } substate++; /* * FIXME after 3.0: Make it possible to disable ATS11 since it * seems to be incompatible with some ISDN adapters (e.g. DataBox * Speed Dragon). Even better would be to detect this when doing * a "Modem Query" */ - if (MODEM_TONEDURATION != gpppdata.modemToneDuration()) + if (MODEM_TONEDURATION != PPPData::data()->modemToneDuration()) vmain = 5; else vmain = 3; return; } if (vmain == 5) { if(!expecting) { - QString sToneDuration = "ATS11=" + QString::number(gpppdata.modemToneDuration()); + QString sToneDuration = "ATS11=" + QString::number(PPPData::data()->modemToneDuration()); QString msg = i18n("Setting ") + sToneDuration; messg->setText(msg); emit debugMessage(msg); - setExpect(gpppdata.modemInitResp()); + setExpect(PPPData::data()->modemInitResp()); writeline(sToneDuration); } vmain = 3; return; } @@ -333,115 +333,115 @@ void ConnectWidget::timerEvent(QTimerEvent *) { if(substate < PPPData::NumInitStrings) { vmain = 0; return; } substate = -1; // skip setting the volume if command is empty - if(gpppdata.volumeInitString().isEmpty()) { + if(PPPData::data()->volumeInitString().isEmpty()) { vmain = 4; return; } messg->setText(i18n("Setting speaker volume...")); emit debugMessage(i18n("Setting speaker volume...")); - setExpect(gpppdata.modemInitResp()); + setExpect(PPPData::data()->modemInitResp()); QString vol("AT"); - vol += gpppdata.volumeInitString(); + vol += PPPData::data()->volumeInitString(); writeline(vol); - usleep(gpppdata.modemInitDelay() * 10000); // 0.01 - 3.0 sec + usleep(PPPData::data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec vmain = 4; return; } } if(vmain == 4) { if(!expecting) { - if(!gpppdata.waitForDialTone()) { + if(!PPPData::data()->waitForDialTone()) { QString msg = i18n("Turning off dial tone waiting..."); messg->setText(msg); emit debugMessage(msg); - setExpect(gpppdata.modemInitResp()); - writeline(gpppdata.modemNoDialToneDetectionStr()); + setExpect(PPPData::data()->modemInitResp()); + writeline(PPPData::data()->modemNoDialToneDetectionStr()); } vmain = 1; return; } } // dial the number and wait to connect if(vmain == 1) { if(!expecting) { timeout_timer->stop(); - timeout_timer->start(gpppdata.modemTimeout()*1000); + timeout_timer->start(PPPData::data()->modemTimeout()*1000); - QStringList &plist = gpppdata.phonenumbers(); - QString bmarg= gpppdata.dialPrefix(); + QStringList &plist = PPPData::data()->phonenumbers(); + QString bmarg= PPPData::data()->dialPrefix(); bmarg += *plist.at(dialnumber); QString bm = i18n("Dialing %1").arg(bmarg); messg->setText(bm); emit debugMessage(bm); - QString pn = gpppdata.modemDialStr(); - pn += gpppdata.dialPrefix(); + QString pn = PPPData::data()->modemDialStr(); + pn += PPPData::data()->dialPrefix(); pn += *plist.at(dialnumber); if(++dialnumber >= plist.count()) dialnumber = 0; writeline(pn); - setExpect(gpppdata.modemConnectResp()); + setExpect(PPPData::data()->modemConnectResp()); vmain = 100; return; } } // wait for connect, but redial if BUSY or wait for user cancel // if NO CARRIER or NO DIALTONE if(vmain == 100) { if(!expecting) { - myreadbuffer = gpppdata.modemConnectResp(); + myreadbuffer = PPPData::data()->modemConnectResp(); setExpect("\n"); vmain = 101; return; } - if(readbuffer.contains(gpppdata.modemBusyResp())) { + if(readbuffer.contains(PPPData::data()->modemBusyResp())) { timeout_timer->stop(); - timeout_timer->start(gpppdata.modemTimeout()*1000); + timeout_timer->start(PPPData::data()->modemTimeout()*1000); messg->setText(i18n("Line busy. Hanging up...")); emit debugPutChar('\n'); Modem::modem->hangup(); - if(gpppdata.busyWait() > 0) { - QString bm = i18n("Line busy. Waiting: %1 seconds").arg(gpppdata.busyWait()); + if(PPPData::data()->busyWait() > 0) { + QString bm = i18n("Line busy. Waiting: %1 seconds").arg(PPPData::data()->busyWait()); messg->setText(bm); emit debugMessage(bm); pausing = true; - pausetimer->start(gpppdata.busyWait()*1000, true); + pausetimer->start(PPPData::data()->busyWait()*1000, true); timeout_timer->stop(); } Modem::modem->setDataMode(false); vmain = 0; substate = -1; return; } - if(readbuffer.contains(gpppdata.modemNoDialtoneResp())) { + if(readbuffer.contains(PPPData::data()->modemNoDialtoneResp())) { timeout_timer->stop(); messg->setText(i18n("No Dialtone")); vmain = 20; Modem::modem->unlockdevice(); return; } - if(readbuffer.contains(gpppdata.modemNoCarrierResp())) { + if(readbuffer.contains(PPPData::data()->modemNoCarrierResp())) { timeout_timer->stop(); messg->setText(i18n("No Carrier")); vmain = 20; Modem::modem->unlockdevice(); return; @@ -454,13 +454,13 @@ void ConnectWidget::timerEvent(QTimerEvent *) { Modem::modem->setDataMode(true); // modem will no longer respond to AT commands emit startAccounting(); // p_kppp->con_win->startClock(); vmain = 2; - scriptTimeout=gpppdata.modemTimeout()*1000; + scriptTimeout=PPPData::data()->modemTimeout()*1000; return; } } // execute the script if(vmain == 2) { @@ -491,16 +491,16 @@ void ConnectWidget::timerEvent(QTimerEvent *) { if (scriptCommand == "Save") { QString bm = i18n("Saving %1").arg(scriptArgument); messg->setText(bm); emit debugMessage(bm); if (scriptArgument.lower() == "password") { - gpppdata.setPassword(scanvar); + PPPData::data()->setPassword(scanvar); p_kppp->setPW_Edit(scanvar); - if(gpppdata.storePassword()) - gpppdata.setStoredPassword(scanvar); + if(PPPData::data()->storePassword()) + PPPData::data()->setStoredPassword(scanvar); firstrunPW = true; } scriptindex++; return; } @@ -510,14 +510,14 @@ void ConnectWidget::timerEvent(QTimerEvent *) { QString bm = i18n("Sending %1"); // replace %USERNAME% and %PASSWORD% QString arg = scriptArgument; QRegExp re1("%USERNAME%"); QRegExp re2("%PASSWORD%"); - arg = arg.replace(re1, gpppdata.storedUsername()); - arg = arg.replace(re2, gpppdata.storedPassword()); + arg = arg.replace(re1, PPPData::data()->storedUsername()); + arg = arg.replace(re2, PPPData::data()->storedPassword()); if (scriptCommand == "Send") bm = bm.arg(scriptArgument); else { for(uint i = 0; i < scriptArgument.length(); i++) bm = bm.arg("*"); @@ -575,37 +575,37 @@ void ConnectWidget::timerEvent(QTimerEvent *) { } if (scriptCommand == "Hangup") { messg->setText(i18n("Hangup")); emit debugMessage(i18n("Hangup")); - writeline(gpppdata.modemHangupStr()); - setExpect(gpppdata.modemHangupResp()); + writeline(PPPData::data()->modemHangupStr()); + setExpect(PPPData::data()->modemHangupResp()); scriptindex++; return; } if (scriptCommand == "Answer") { timeout_timer->stop(); messg->setText(i18n("Answer")); emit debugMessage(i18n("Answer")); - setExpect(gpppdata.modemRingResp()); + setExpect(PPPData::data()->modemRingResp()); vmain = 150; return; } if (scriptCommand == "ID") { QString bm = i18n("ID %1").arg(scriptArgument); messg->setText(bm); emit debugMessage(bm); - QString idstring = gpppdata.storedUsername(); + QString idstring = PPPData::data()->storedUsername(); if(!idstring.isEmpty() && firstrunID) { // the user entered an Id on the main kppp dialog writeline(idstring); firstrunID = false; scriptindex++; @@ -635,13 +635,13 @@ void ConnectWidget::timerEvent(QTimerEvent *) { if (scriptCommand == "Password") { QString bm = i18n("Password %1").arg(scriptArgument); messg->setText(bm); emit debugMessage(bm); - QString pwstring = gpppdata.password(); + QString pwstring = PPPData::data()->password(); if(!pwstring.isEmpty() && firstrunPW) { // the user entered a password on the main kppp dialog writeline(pwstring); firstrunPW = false; scriptindex++; @@ -782,14 +782,14 @@ void ConnectWidget::timerEvent(QTimerEvent *) { } // this is a subroutine for the "Answer" script option if(vmain == 150) { if(!expecting) { - writeline(gpppdata.modemAnswerStr()); - setExpect(gpppdata.modemAnswerResp()); + writeline(PPPData::data()->modemAnswerStr()); + setExpect(PPPData::data()->modemAnswerResp()); vmain = 2; scriptindex++; return; } } @@ -811,13 +811,13 @@ void ConnectWidget::timerEvent(QTimerEvent *) { timeout_timer->stop(); if_timeout_timer->stop(); // better be sure. // stop reading of data Modem::modem->stop(); - if(gpppdata.authMethod() == AUTH_TERMINAL) { + if(PPPData::data()->authMethod() == AUTH_TERMINAL) { // if (termwindow) { // delete termwindow; // termwindow = 0L; // this->show(); // } else { // termwindow = new LoginTerm(0L, 0L); @@ -832,27 +832,27 @@ void ConnectWidget::timerEvent(QTimerEvent *) { // Modem::readtty() from re-enabling the socket notifier. // The port is still held open by the helper process. Modem::modem->closetty(); killTimer( main_timer_ID ); - if_timeout_timer->start(gpppdata.pppdTimeout()*1000); - qDebug( "started if timeout timer with %i", gpppdata.pppdTimeout()*1000); + if_timeout_timer->start(PPPData::data()->pppdTimeout()*1000); + qDebug( "started if timeout timer with %i", PPPData::data()->pppdTimeout()*1000); // find out PPP interface and notify the stats module // stats->setUnit(pppInterfaceNumber()); qApp->flushX(); semaphore = true; result = execppp(); emit debugMessage(i18n("Starting pppd...")); qDebug("execppp() returned with return-code %i", result ); if(result) { - if(!gpppdata.autoDNS()) + if(!PPPData::data()->autoDNS()) adddns(); // O.K we are done here, let's change over to the if_waiting loop // where we wait for the ppp if (interface) to come up. emit if_waiting_signal(); @@ -1060,13 +1060,13 @@ void ConnectWidget::setExpect(const QString &n) { void ConnectWidget::if_waiting_timed_out() { if_timer->stop(); if_timeout_timer->stop(); qDebug("if_waiting_timed_out()"); - gpppdata.setpppdError(E_IF_TIMEOUT); + PPPData::data()->setpppdError(E_IF_TIMEOUT); // let's kill the stuck pppd Modem::modem->killPPPDaemon(); emit stopAccounting(); // p_kppp->con_win->stopClock(); @@ -1085,13 +1085,13 @@ void ConnectWidget::pppdDied() void ConnectWidget::if_waiting_slot() { messg->setText(i18n("Logging on to network...")); // if(!stats->ifIsUp()) { -// if(gpppdata.pppdError() != 0) { +// if(PPPData::data()->pppdError() != 0) { // // we are here if pppd died immediately after starting it. // pppdDied(); // // error message handled in main.cpp: sigPPPDDied() // return; // } @@ -1102,27 +1102,27 @@ void ConnectWidget::if_waiting_slot() { // O.K the ppp interface is up and running // give it a few time to come up completly (0.2 seconds) if_timeout_timer->stop(); if_timer->stop(); usleep(200000); - if(gpppdata.autoDNS()) + if(PPPData::data()->autoDNS()) addpeerdns(); // Close the debugging window. If we are connected, we // are not really interested in debug output emit closeDebugWindow(); // p_kppp->statdlg->take_stats(); // start taking ppp statistics auto_hostname(); - if(!gpppdata.command_on_connect().isEmpty()) { + if(!PPPData::data()->command_on_connect().isEmpty()) { messg->setText(i18n("Running startup command...")); // make sure that we don't get any async errors qApp->flushX(); - execute_command(gpppdata.command_on_connect()); + execute_command(PPPData::data()->command_on_connect()); messg->setText(i18n("Done")); } // remove the authentication file Modem::modem->removeSecret(AUTH_PAP); Modem::modem->removeSecret(AUTH_CHAP); @@ -1138,21 +1138,21 @@ void ConnectWidget::if_waiting_slot() { // accounting / non-accounting mode // if(p_kppp->acct != 0) // p_kppp->con_win->accounting(p_kppp->acct->running()); // else // p_kppp->con_win->accounting(false); - if (gpppdata.get_dock_into_panel()) { + if (PPPData::data()->get_dock_into_panel()) { // DockWidget::dock_widget->show(); // DockWidget::dock_widget->take_stats(); // this->hide(); } else { // p_kppp->con_win->show(); - if(gpppdata.get_iconify_on_connect()) { + if(PPPData::data()->get_iconify_on_connect()) { // p_kppp->con_win->showMinimized(); } } Modem::modem->closetty(); } @@ -1165,78 +1165,78 @@ bool ConnectWidget::execppp() { // as of version 2.3.6 pppd falls back to the real user rights when // opening a device given in a command line. To avoid permission conflicts // we'll simply leave this argument away. pppd will then use the default tty // which is the serial port we connected stdin/stdout to in opener.cpp. // command += " "; - // command += gpppdata.modemDevice(); + // command += PPPData::data()->modemDevice(); - command += " " + gpppdata.speed(); + command += " " + PPPData::data()->speed(); command += " -detach"; - if(gpppdata.ipaddr() != "0.0.0.0" || - gpppdata.gateway() != "0.0.0.0") { - if(gpppdata.ipaddr() != "0.0.0.0") { + if(PPPData::data()->ipaddr() != "0.0.0.0" || + PPPData::data()->gateway() != "0.0.0.0") { + if(PPPData::data()->ipaddr() != "0.0.0.0") { command += " "; - command += gpppdata.ipaddr(); + command += PPPData::data()->ipaddr(); command += ":"; } else { command += " "; command += ":"; } - if(gpppdata.gateway() != "0.0.0.0") - command += gpppdata.gateway(); + if(PPPData::data()->gateway() != "0.0.0.0") + command += PPPData::data()->gateway(); } - if(gpppdata.subnetmask() != "0.0.0.0") - command += " netmask " + gpppdata.subnetmask(); + if(PPPData::data()->subnetmask() != "0.0.0.0") + command += " netmask " + PPPData::data()->subnetmask(); - if(gpppdata.flowcontrol() != "None") { - if(gpppdata.flowcontrol() == "CRTSCTS") + if(PPPData::data()->flowcontrol() != "None") { + if(PPPData::data()->flowcontrol() == "CRTSCTS") command += " crtscts"; else command += " xonxoff"; } - if(gpppdata.defaultroute()) + if(PPPData::data()->defaultroute()) command += " defaultroute"; - if(gpppdata.autoDNS()) + if(PPPData::data()->autoDNS()) command += " usepeerdns"; - QStringList &arglist = gpppdata.pppdArgument(); + QStringList &arglist = PPPData::data()->pppdArgument(); for ( QStringList::Iterator it = arglist.begin(); it != arglist.end(); ++it ) { command += " " + *it; } // PAP settings - if(gpppdata.authMethod() == AUTH_PAP) { + if(PPPData::data()->authMethod() == AUTH_PAP) { command += " -chap user "; - command = command + "\"" + gpppdata.storedUsername() + "\""; + command = command + "\"" + PPPData::data()->storedUsername() + "\""; } // CHAP settings - if(gpppdata.authMethod() == AUTH_CHAP) { + if(PPPData::data()->authMethod() == AUTH_CHAP) { command += " -pap user "; - command = command + "\"" + gpppdata.storedUsername() + "\""; + command = command + "\"" + PPPData::data()->storedUsername() + "\""; } // PAP/CHAP settings - if(gpppdata.authMethod() == AUTH_PAPCHAP) { + if(PPPData::data()->authMethod() == AUTH_PAPCHAP) { command += " user "; - command = command + "\"" + gpppdata.storedUsername() + "\""; + command = command + "\"" + PPPData::data()->storedUsername() + "\""; } // check for debug - if(gpppdata.getPPPDebug()) + if(PPPData::data()->getPPPDebug()) command += " debug"; if (command.length() > MAX_CMDLEN) { QMessageBox::critical(this, "error", i18n( "pppd command + command-line arguments exceed " "2024 characters in length." @@ -1274,14 +1274,14 @@ void auto_hostname() { char tmp_str[100]; // buffer overflow safe gethostname(tmp_str, sizeof(tmp_str)); tmp_str[sizeof(tmp_str)-1]=0; // panic old_hostname=tmp_str; // copy to QString - // if (!p_kppp->stats->local_ip_address.isEmpty() && gpppdata.autoname()) { - if ( gpppdata.autoname()) { + // if (!p_kppp->stats->local_ip_address.isEmpty() && PPPData::data()->autoname()) { + if ( PPPData::data()->autoname()) { // local_ip.s_addr=inet_addr(p_kppp->stats->local_ip_address.ascii()); hostname_entry=gethostbyaddr((const char *)&local_ip,sizeof(in_addr),AF_INET); if (hostname_entry != 0L) { new_hostname=hostname_entry->h_name; dot=new_hostname.find('.'); @@ -1329,13 +1329,13 @@ void add_domain(const QString &domain) { write(fd, tmp.data(), tmp.length()); for(int j=0; j < i; j++) { if((resolv[j].contains("domain") || ( resolv[j].contains("nameserver") && !resolv[j].contains("#kppp temp entry") - && gpppdata.exDNSDisabled())) + && PPPData::data()->exDNSDisabled())) && !resolv[j].contains("#entry disabled by kppp")) { QCString tmp = "# " + resolv[j].local8Bit() + " \t#entry disabled by kppp\n"; write(fd, tmp, tmp.length()); } else { @@ -1352,24 +1352,24 @@ void add_domain(const QString &domain) { // adds the DNS entries in the /etc/resolv.conf file void adddns() { int fd; if ((fd = Modem::modem->openResolv(O_WRONLY|O_APPEND)) >= 0) { - QStringList &dnslist = gpppdata.dns(); + QStringList &dnslist = PPPData::data()->dns(); for ( QStringList::Iterator it = dnslist.begin(); it != dnslist.end(); ++it ) { QCString dns = "nameserver " + (*it).local8Bit() + " \t#kppp temp entry\n"; write(fd, dns.data(), dns.length()); } close(fd); } - add_domain(gpppdata.domain()); + add_domain(PPPData::data()->domain()); } void addpeerdns() { int fd, fd2; if((fd = Modem::modem->openResolv(O_WRONLY|O_APPEND)) >= 0) { @@ -1384,13 +1384,13 @@ void addpeerdns() { } close(fd2); } else fprintf(stderr, "failed to read from /etc/ppp/resolv.conf\n"); close(fd); } - add_domain(gpppdata.domain()); + add_domain(PPPData::data()->domain()); } // remove the dns entries from the /etc/resolv.conf file void removedns() { int fd; |