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 | |||
@@ -98,13 +98,13 @@ Modem::~Modem() { | |||
98 | 98 | ||
99 | 99 | ||
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; |
109 | break; | 109 | break; |
110 | case 96: | 110 | case 96: |
@@ -148,23 +148,23 @@ speed_t Modem::modemspeed() { | |||
148 | 148 | ||
149 | bool Modem::opentty() { | 149 | 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; |
159 | } | 159 | } |
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; |
169 | return false; | 169 | return false; |
170 | } | 170 | } |
@@ -206,14 +206,14 @@ bool Modem::opentty() { | |||
206 | tty.c_cflag |= CLOCAL; // ignore modem status lines | 206 | tty.c_cflag |= CLOCAL; // ignore modem status lines |
207 | tty.c_iflag = IGNBRK | IGNPAR /* | ISTRIP */ ; | 207 | tty.c_iflag = IGNBRK | IGNPAR /* | ISTRIP */ ; |
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; |
218 | tty.c_cc[VSTOP] = 0x13; /* DC3 = XOFF = ^S */ | 218 | tty.c_cc[VSTOP] = 0x13; /* DC3 = XOFF = ^S */ |
219 | tty.c_cc[VSTART] = 0x11; /* DC1 = XON = ^Q */ | 219 | tty.c_cc[VSTART] = 0x11; /* DC1 = XON = ^Q */ |
@@ -336,13 +336,13 @@ bool Modem::writeChar(unsigned char c) { | |||
336 | 336 | ||
337 | bool Modem::writeLine(const char *buf) { | 337 | 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'; |
347 | else if(term == "CR/LF") { | 347 | else if(term == "CR/LF") { |
348 | b[len++]='\r'; | 348 | b[len++]='\r'; |
@@ -376,15 +376,15 @@ bool Modem::hangup() { | |||
376 | 376 | ||
377 | // is this Escape & HangupStr stuff really necessary ? (Harri) | 377 | // is this Escape & HangupStr stuff really necessary ? (Harri) |
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 |
389 | signal(SIGALRM, alarm_handler); | 389 | signal(SIGALRM, alarm_handler); |
390 | alarm(2); | 390 | alarm(2); |
@@ -414,13 +414,13 @@ bool Modem::hangup() { | |||
414 | ioctl(modemfd, TIOCMSET, &modemstat); | 414 | ioctl(modemfd, TIOCMSET, &modemstat); |
415 | ioctl(modemfd, TIOCMGET, &modemstat); | 415 | ioctl(modemfd, TIOCMGET, &modemstat); |
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); |
425 | #endif | 425 | #endif |
426 | return true; | 426 | return true; |
@@ -437,17 +437,17 @@ void Modem::escape_to_command_mode() { | |||
437 | // Need to send properly timed escape sequence to put modem in command state. | 437 | // Need to send properly timed escape sequence to put modem in command state. |
438 | // Escape codes and guard times are controlled by S2 and S12 values. | 438 | // Escape codes and guard times are controlled by S2 and S12 values. |
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 | ||
452 | 452 | ||
453 | const QString Modem::modemMessage() { | 453 | const QString Modem::modemMessage() { |
@@ -557,22 +557,22 @@ QString Modem::parseModemSpeed(const QString &s) { | |||
557 | // Lock modem device. Returns 0 on success 1 if the modem is locked and -1 if | 557 | // Lock modem device. Returns 0 on success 1 if the modem is locked and -1 if |
558 | // a lock file can't be created ( permission problem ) | 558 | // a lock file can't be created ( permission problem ) |
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) { |
577 | // Mario: it's not necessary to read more than lets say 32 bytes. If | 577 | // Mario: it's not necessary to read more than lets say 32 bytes. If |
578 | // file has more than 32 bytes, skip the rest | 578 | // file has more than 32 bytes, skip the rest |
@@ -597,13 +597,13 @@ if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) { | |||
597 | return 1; | 597 | return 1; |
598 | 598 | ||
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 | ||
608 | write(fd, newlock, strlen(newlock)); | 608 | write(fd, newlock, strlen(newlock)); |
609 | close(fd); | 609 | close(fd); |