Diffstat (limited to 'noncore/settings/networksettings/ppp/modem.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/ppp/modem.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/noncore/settings/networksettings/ppp/modem.cpp b/noncore/settings/networksettings/ppp/modem.cpp index a2f77c5..cd5d21c 100644 --- a/noncore/settings/networksettings/ppp/modem.cpp +++ b/noncore/settings/networksettings/ppp/modem.cpp @@ -92,25 +92,25 @@ Modem::Modem() } Modem::~Modem() { modem = 0; } speed_t Modem::modemspeed() { // convert the string modem speed int the gpppdata object to a t_speed type // to set the modem. The constants here should all be ifdef'd because // other systems may not have them - int i = gpppdata.speed().toInt()/100; + int i = PPPData::data()->speed().toInt()/100; switch(i) { case 24: return B2400; break; case 96: return B9600; break; case 192: return B19200; break; case 384: @@ -142,35 +142,35 @@ speed_t Modem::modemspeed() { default: return B38400; break; } } bool Modem::opentty() { // int flags; //begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { close(modemfd); -// device = "/dev/modem";//deviceByIndex(request.modem.deviceNum); + device = PPPData::data()->modemDevice(); if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) { qDebug("error opening modem device !"); errmsg = i18n("Unable to open modem."); return false; } //bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { //} #if 0 - if(gpppdata.UseCDLine()) { + if(PPPData::data()->UseCDLine()) { if(ioctl(modemfd, TIOCMGET, &flags) == -1) { errmsg = i18n("Unable to detect state of CD line."); ::close(modemfd); modemfd = -1; return false; } if ((flags&TIOCM_CD) == 0) { errmsg = i18n("The modem is not ready."); ::close(modemfd); modemfd = -1; return false; } @@ -200,26 +200,26 @@ bool Modem::opentty() { tty.c_cc[VTIME] = 0; tty.c_oflag = 0; tty.c_lflag = 0; tty.c_cflag &= ~(CSIZE | CSTOPB | PARENB); tty.c_cflag |= CS8 | CREAD; tty.c_cflag |= CLOCAL; // ignore modem status lines tty.c_iflag = IGNBRK | IGNPAR /* | ISTRIP */ ; tty.c_lflag &= ~ICANON; // non-canonical mode tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHOKE); - if(gpppdata.flowcontrol() != "None") { - if(gpppdata.flowcontrol() == "CRTSCTS") { + if(PPPData::data()->flowcontrol() != "None") { + if(PPPData::data()->flowcontrol() == "CRTSCTS") { tty.c_cflag |= CRTSCTS; } else { tty.c_iflag |= IXON | IXOFF; tty.c_cc[VSTOP] = 0x13; /* DC3 = XOFF = ^S */ tty.c_cc[VSTART] = 0x11; /* DC1 = XON = ^Q */ } } else { tty.c_cflag &= ~CRTSCTS; tty.c_iflag &= ~(IXON | IXOFF); } @@ -330,25 +330,25 @@ bool Modem::writeChar(unsigned char c) { } } while(s == 0); return true; } bool Modem::writeLine(const char *buf) { int len = strlen(buf); char *b = new char[len+2]; memcpy(b, buf, len); // different modems seem to need different line terminations - QString term = gpppdata.enter(); + QString term = PPPData::data()->enter(); if(term == "LF") b[len++]='\n'; else if(term == "CR") b[len++]='\r'; else if(term == "CR/LF") { b[len++]='\r'; b[len++]='\n'; } int l = len; while(l) { int wr = write(modemfd, &b[len-l], l); if(wr < 0) { @@ -370,27 +370,27 @@ bool Modem::hangup() { // this is probably the most imporant snippet of code in the whole of // kppp. If people complain about kppp being stuck, this piece of code // is most likely the reason. struct termios temptty; if(modemfd >= 0) { // is this Escape & HangupStr stuff really necessary ? (Harri) if (data_mode) escape_to_command_mode(); // Then hangup command - writeLine(gpppdata.modemHangupStr().local8Bit()); + writeLine(PPPData::data()->modemHangupStr().local8Bit()); - usleep(gpppdata.modemInitDelay() * 10000); // 0.01 - 3.0 sec + usleep(PPPData::data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec #ifndef DEBUG_WO_DIALING if (sigsetjmp(jmp_buffer, 1) == 0) { // set alarm in case tcsendbreak() hangs signal(SIGALRM, alarm_handler); alarm(2); tcsendbreak(modemfd, 0); alarm(0); signal(SIGALRM, SIG_IGN); } else { @@ -408,52 +408,52 @@ bool Modem::hangup() { cfsetispeed(&temptty, B0); tcsetattr(modemfd, TCSAFLUSH, &temptty); #else int modemstat; ioctl(modemfd, TIOCMGET, &modemstat); modemstat &= ~TIOCM_DTR; ioctl(modemfd, TIOCMSET, &modemstat); ioctl(modemfd, TIOCMGET, &modemstat); modemstat |= TIOCM_DTR; ioctl(modemfd, TIOCMSET, &modemstat); #endif - usleep(gpppdata.modemInitDelay() * 10000); // 0.01 - 3.0 secs + usleep(PPPData::data()->modemInitDelay() * 10000); // 0.01 - 3.0 secs cfsetospeed(&temptty, modemspeed()); cfsetispeed(&temptty, modemspeed()); tcsetattr(modemfd, TCSAFLUSH, &temptty); #endif return true; } else return false; } void Modem::escape_to_command_mode() { // Send Properly bracketed escape code to put the modem back into command state. // A modem will accept AT commands only when it is in command state. // When a modem sends the host the CONNECT string, that signals // that the modem is now in the connect state (no long accepts AT commands.) // Need to send properly timed escape sequence to put modem in command state. // Escape codes and guard times are controlled by S2 and S12 values. // tcflush(modemfd, TCIOFLUSH); // +3 because quiet time must be greater than guard time. - usleep((gpppdata.modemEscapeGuardTime()+3)*20000); - QCString tmp = gpppdata.modemEscapeStr().local8Bit(); + usleep((PPPData::data()->modemEscapeGuardTime()+3)*20000); + QCString tmp = PPPData::data()->modemEscapeStr().local8Bit(); write(modemfd, tmp.data(), tmp.length()); tcflush(modemfd, TCIOFLUSH); - usleep((gpppdata.modemEscapeGuardTime()+3)*20000); + usleep((PPPData::data()->modemEscapeGuardTime()+3)*20000); data_mode = false; } const QString Modem::modemMessage() { return errmsg; } QString Modem::parseModemSpeed(const QString &s) { // this is a small (and bad) parser for modem speeds @@ -551,34 +551,34 @@ QString Modem::parseModemSpeed(const QString &s) { qDebug( "The parsed result is: %s", result.latin1()); return result; } // Lock modem device. Returns 0 on success 1 if the modem is locked and -1 if // a lock file can't be created ( permission problem ) int Modem::lockdevice() { int fd; char newlock[80]=""; // safe - if(!gpppdata.modemLockFile()) { + if(!PPPData::data()->modemLockFile()) { qDebug("The user doesn't want a lockfile."); return 0; } if (modem_is_locked) return 1; QString lockfile = LOCK_DIR"/LCK.."; - lockfile += gpppdata.modemDevice().mid(5); // append everything after /dev/ + lockfile += PPPData::data()->modemDevice().mid(5); // append everything after /dev/ if(access(QFile::encodeName(lockfile), F_OK) == 0) { // if ((fd = Requester::rq-> if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) { // Mario: it's not necessary to read more than lets say 32 bytes. If // file has more than 32 bytes, skip the rest char oldlock[33]; // safe int sz = read(fd, &oldlock, 32); close (fd); if (sz <= 0) return 1; oldlock[sz] = '\0'; @@ -591,25 +591,25 @@ if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) { // found a pid in lockfile ? if (match < 1 || oldpid <= 0) return 1; // check if process exists if (kill((pid_t)oldpid, 0) == 0 || errno != ESRCH) return 1; qDebug( "lockfile is stale" ); } } - fd = openLockfile(gpppdata.modemDevice(),O_WRONLY|O_TRUNC|O_CREAT); + fd = openLockfile(PPPData::data()->modemDevice(),O_WRONLY|O_TRUNC|O_CREAT); if(fd >= 0) { sprintf(newlock,"%010d\n", getpid()); qDebug("Locking Device: %s", newlock); write(fd, newlock, strlen(newlock)); close(fd); modem_is_locked=true; return 0; } return -1; |