Diffstat (limited to 'noncore/settings/networksettings/ppp/modem.cpp') (more/less context) (ignore 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 | |||
@@ -100,9 +100,9 @@ Modem::~Modem() { | |||
100 | speed_t Modem::modemspeed() { | 100 | speed_t Modem::modemspeed() { |
101 | // convert the string modem speed int the gpppdata object to a t_speed type | 101 | // convert the string modem speed int the gpppdata object to a t_speed type |
102 | // to set the modem. The constants here should all be ifdef'd because | 102 | // to set the modem. The constants here should all be ifdef'd because |
103 | // other systems may not have them | 103 | // other systems may not have them |
104 | int i = gpppdata.speed().toInt()/100; | 104 | int i = PPPData::data()->speed().toInt()/100; |
105 | 105 | ||
106 | switch(i) { | 106 | switch(i) { |
107 | case 24: | 107 | case 24: |
108 | return B2400; | 108 | return B2400; |
@@ -150,9 +150,9 @@ bool Modem::opentty() { | |||
150 | // int flags; | 150 | // int flags; |
151 | 151 | ||
152 | //begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { | 152 | //begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { |
153 | close(modemfd); | 153 | close(modemfd); |
154 | // device = "/dev/modem";//deviceByIndex(request.modem.deviceNum); | 154 | device = PPPData::data()->modemDevice(); |
155 | if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) { | 155 | if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) { |
156 | qDebug("error opening modem device !"); | 156 | qDebug("error opening modem device !"); |
157 | errmsg = i18n("Unable to open modem."); | 157 | errmsg = i18n("Unable to open modem."); |
158 | return false; | 158 | return false; |
@@ -160,9 +160,9 @@ bool Modem::opentty() { | |||
160 | //bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { | 160 | //bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { |
161 | //} | 161 | //} |
162 | 162 | ||
163 | #if 0 | 163 | #if 0 |
164 | if(gpppdata.UseCDLine()) { | 164 | if(PPPData::data()->UseCDLine()) { |
165 | if(ioctl(modemfd, TIOCMGET, &flags) == -1) { | 165 | if(ioctl(modemfd, TIOCMGET, &flags) == -1) { |
166 | errmsg = i18n("Unable to detect state of CD line."); | 166 | errmsg = i18n("Unable to detect state of CD line."); |
167 | ::close(modemfd); | 167 | ::close(modemfd); |
168 | modemfd = -1; | 168 | modemfd = -1; |
@@ -208,10 +208,10 @@ bool Modem::opentty() { | |||
208 | tty.c_lflag &= ~ICANON; // non-canonical mode | 208 | tty.c_lflag &= ~ICANON; // non-canonical mode |
209 | tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHOKE); | 209 | tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHOKE); |
210 | 210 | ||
211 | 211 | ||
212 | if(gpppdata.flowcontrol() != "None") { | 212 | if(PPPData::data()->flowcontrol() != "None") { |
213 | if(gpppdata.flowcontrol() == "CRTSCTS") { | 213 | if(PPPData::data()->flowcontrol() == "CRTSCTS") { |
214 | tty.c_cflag |= CRTSCTS; | 214 | tty.c_cflag |= CRTSCTS; |
215 | } | 215 | } |
216 | else { | 216 | else { |
217 | tty.c_iflag |= IXON | IXOFF; | 217 | tty.c_iflag |= IXON | IXOFF; |
@@ -338,9 +338,9 @@ bool Modem::writeLine(const char *buf) { | |||
338 | int len = strlen(buf); | 338 | int len = strlen(buf); |
339 | char *b = new char[len+2]; | 339 | char *b = new char[len+2]; |
340 | memcpy(b, buf, len); | 340 | memcpy(b, buf, len); |
341 | // different modems seem to need different line terminations | 341 | // different modems seem to need different line terminations |
342 | QString term = gpppdata.enter(); | 342 | QString term = PPPData::data()->enter(); |
343 | if(term == "LF") | 343 | if(term == "LF") |
344 | b[len++]='\n'; | 344 | b[len++]='\n'; |
345 | else if(term == "CR") | 345 | else if(term == "CR") |
346 | b[len++]='\r'; | 346 | b[len++]='\r'; |
@@ -378,11 +378,11 @@ bool Modem::hangup() { | |||
378 | 378 | ||
379 | if (data_mode) escape_to_command_mode(); | 379 | if (data_mode) escape_to_command_mode(); |
380 | 380 | ||
381 | // Then hangup command | 381 | // Then hangup command |
382 | writeLine(gpppdata.modemHangupStr().local8Bit()); | 382 | writeLine(PPPData::data()->modemHangupStr().local8Bit()); |
383 | 383 | ||
384 | usleep(gpppdata.modemInitDelay() * 10000); // 0.01 - 3.0 sec | 384 | usleep(PPPData::data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec |
385 | 385 | ||
386 | #ifndef DEBUG_WO_DIALING | 386 | #ifndef DEBUG_WO_DIALING |
387 | if (sigsetjmp(jmp_buffer, 1) == 0) { | 387 | if (sigsetjmp(jmp_buffer, 1) == 0) { |
388 | // set alarm in case tcsendbreak() hangs | 388 | // set alarm in case tcsendbreak() hangs |
@@ -416,9 +416,9 @@ bool Modem::hangup() { | |||
416 | modemstat |= TIOCM_DTR; | 416 | modemstat |= TIOCM_DTR; |
417 | ioctl(modemfd, TIOCMSET, &modemstat); | 417 | ioctl(modemfd, TIOCMSET, &modemstat); |
418 | #endif | 418 | #endif |
419 | 419 | ||
420 | usleep(gpppdata.modemInitDelay() * 10000); // 0.01 - 3.0 secs | 420 | usleep(PPPData::data()->modemInitDelay() * 10000); // 0.01 - 3.0 secs |
421 | 421 | ||
422 | cfsetospeed(&temptty, modemspeed()); | 422 | cfsetospeed(&temptty, modemspeed()); |
423 | cfsetispeed(&temptty, modemspeed()); | 423 | cfsetispeed(&temptty, modemspeed()); |
424 | tcsetattr(modemfd, TCSAFLUSH, &temptty); | 424 | tcsetattr(modemfd, TCSAFLUSH, &temptty); |
@@ -439,13 +439,13 @@ void Modem::escape_to_command_mode() { | |||
439 | // | 439 | // |
440 | tcflush(modemfd, TCIOFLUSH); | 440 | tcflush(modemfd, TCIOFLUSH); |
441 | 441 | ||
442 | // +3 because quiet time must be greater than guard time. | 442 | // +3 because quiet time must be greater than guard time. |
443 | usleep((gpppdata.modemEscapeGuardTime()+3)*20000); | 443 | usleep((PPPData::data()->modemEscapeGuardTime()+3)*20000); |
444 | QCString tmp = gpppdata.modemEscapeStr().local8Bit(); | 444 | QCString tmp = PPPData::data()->modemEscapeStr().local8Bit(); |
445 | write(modemfd, tmp.data(), tmp.length()); | 445 | write(modemfd, tmp.data(), tmp.length()); |
446 | tcflush(modemfd, TCIOFLUSH); | 446 | tcflush(modemfd, TCIOFLUSH); |
447 | usleep((gpppdata.modemEscapeGuardTime()+3)*20000); | 447 | usleep((PPPData::data()->modemEscapeGuardTime()+3)*20000); |
448 | 448 | ||
449 | data_mode = false; | 449 | data_mode = false; |
450 | } | 450 | } |
451 | 451 | ||
@@ -559,18 +559,18 @@ QString Modem::parseModemSpeed(const QString &s) { | |||
559 | int Modem::lockdevice() { | 559 | int Modem::lockdevice() { |
560 | int fd; | 560 | int fd; |
561 | char newlock[80]=""; // safe | 561 | char newlock[80]=""; // safe |
562 | 562 | ||
563 | if(!gpppdata.modemLockFile()) { | 563 | if(!PPPData::data()->modemLockFile()) { |
564 | qDebug("The user doesn't want a lockfile."); | 564 | qDebug("The user doesn't want a lockfile."); |
565 | return 0; | 565 | return 0; |
566 | } | 566 | } |
567 | 567 | ||
568 | if (modem_is_locked) | 568 | if (modem_is_locked) |
569 | return 1; | 569 | return 1; |
570 | 570 | ||
571 | QString lockfile = LOCK_DIR"/LCK.."; | 571 | QString lockfile = LOCK_DIR"/LCK.."; |
572 | lockfile += gpppdata.modemDevice().mid(5); // append everything after /dev/ | 572 | lockfile += PPPData::data()->modemDevice().mid(5); // append everything after /dev/ |
573 | 573 | ||
574 | if(access(QFile::encodeName(lockfile), F_OK) == 0) { | 574 | if(access(QFile::encodeName(lockfile), F_OK) == 0) { |
575 | // if ((fd = Requester::rq-> | 575 | // if ((fd = Requester::rq-> |
576 | if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) { | 576 | if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) { |
@@ -599,9 +599,9 @@ if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) { | |||
599 | qDebug( "lockfile is stale" ); | 599 | qDebug( "lockfile is stale" ); |
600 | } | 600 | } |
601 | } | 601 | } |
602 | 602 | ||
603 | fd = openLockfile(gpppdata.modemDevice(),O_WRONLY|O_TRUNC|O_CREAT); | 603 | fd = openLockfile(PPPData::data()->modemDevice(),O_WRONLY|O_TRUNC|O_CREAT); |
604 | if(fd >= 0) { | 604 | if(fd >= 0) { |
605 | sprintf(newlock,"%010d\n", getpid()); | 605 | sprintf(newlock,"%010d\n", getpid()); |
606 | qDebug("Locking Device: %s", newlock); | 606 | qDebug("Locking Device: %s", newlock); |
607 | 607 | ||