summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/ppp/modem.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings/ppp/modem.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/modem.cpp30
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
@@ -80,49 +80,49 @@ const char* pppdPath() {
80 80
81 81
82Modem::Modem() 82Modem::Modem()
83{ 83{
84 if (Modem::modem != 0) return; //CORRECT? 84 if (Modem::modem != 0) return; //CORRECT?
85 modemfd = -1; 85 modemfd = -1;
86 sn = 0L; 86 sn = 0L;
87 data_mode = false; 87 data_mode = false;
88 modem_is_locked = false; 88 modem_is_locked = false;
89 lockfile[0] = '\0'; 89 lockfile[0] = '\0';
90 device = "/dev/modem"; 90 device = "/dev/modem";
91 modem = this; 91 modem = this;
92} 92}
93 93
94 94
95Modem::~Modem() { 95Modem::~Modem() {
96 modem = 0; 96 modem = 0;
97} 97}
98 98
99 99
100speed_t Modem::modemspeed() { 100speed_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:
111 return B9600; 111 return B9600;
112 break; 112 break;
113 case 192: 113 case 192:
114 return B19200; 114 return B19200;
115 break; 115 break;
116 case 384: 116 case 384:
117 return B38400; 117 return B38400;
118 break; 118 break;
119#ifdef B57600 119#ifdef B57600
120 case 576: 120 case 576:
121 return B57600; 121 return B57600;
122 break; 122 break;
123#endif 123#endif
124 124
125#ifdef B115200 125#ifdef B115200
126 case 1152: 126 case 1152:
127 return B115200; 127 return B115200;
128 break; 128 break;
@@ -130,108 +130,108 @@ speed_t Modem::modemspeed() {
130 130
131#ifdef B230400 131#ifdef B230400
132 case 2304: 132 case 2304:
133 return B230400; 133 return B230400;
134 break; 134 break;
135#endif 135#endif
136 136
137#ifdef B460800 137#ifdef B460800
138 case 4608: 138 case 4608:
139 return B460800; 139 return B460800;
140 break; 140 break;
141#endif 141#endif
142 142
143 default: 143 default:
144 return B38400; 144 return B38400;
145 break; 145 break;
146 } 146 }
147} 147}
148 148
149bool Modem::opentty() { 149bool 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 }
171 if ((flags&TIOCM_CD) == 0) { 171 if ((flags&TIOCM_CD) == 0) {
172 errmsg = i18n("The modem is not ready."); 172 errmsg = i18n("The modem is not ready.");
173 ::close(modemfd); 173 ::close(modemfd);
174 modemfd = -1; 174 modemfd = -1;
175 return false; 175 return false;
176 } 176 }
177 } 177 }
178#endif 178#endif
179 179
180 tcdrain (modemfd); 180 tcdrain (modemfd);
181 tcflush (modemfd, TCIOFLUSH); 181 tcflush (modemfd, TCIOFLUSH);
182 182
183 if(tcgetattr(modemfd, &tty) < 0){ 183 if(tcgetattr(modemfd, &tty) < 0){
184 // this helps in some cases 184 // this helps in some cases
185 tcsendbreak(modemfd, 0); 185 tcsendbreak(modemfd, 0);
186 sleep(1); 186 sleep(1);
187 if(tcgetattr(modemfd, &tty) < 0){ 187 if(tcgetattr(modemfd, &tty) < 0){
188 errmsg = i18n("The modem is busy."); 188 errmsg = i18n("The modem is busy.");
189 ::close(modemfd); 189 ::close(modemfd);
190 modemfd = -1; 190 modemfd = -1;
191 return false; 191 return false;
192 } 192 }
193 } 193 }
194 194
195 memset(&initial_tty,'\0',sizeof(initial_tty)); 195 memset(&initial_tty,'\0',sizeof(initial_tty));
196 196
197 initial_tty = tty; 197 initial_tty = tty;
198 198
199 tty.c_cc[VMIN] = 0; // nonblocking 199 tty.c_cc[VMIN] = 0; // nonblocking
200 tty.c_cc[VTIME] = 0; 200 tty.c_cc[VTIME] = 0;
201 tty.c_oflag = 0; 201 tty.c_oflag = 0;
202 tty.c_lflag = 0; 202 tty.c_lflag = 0;
203 203
204 tty.c_cflag &= ~(CSIZE | CSTOPB | PARENB); 204 tty.c_cflag &= ~(CSIZE | CSTOPB | PARENB);
205 tty.c_cflag |= CS8 | CREAD; 205 tty.c_cflag |= CS8 | CREAD;
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 */
220 } 220 }
221 } 221 }
222 else { 222 else {
223 tty.c_cflag &= ~CRTSCTS; 223 tty.c_cflag &= ~CRTSCTS;
224 tty.c_iflag &= ~(IXON | IXOFF); 224 tty.c_iflag &= ~(IXON | IXOFF);
225 } 225 }
226 226
227 cfsetospeed(&tty, modemspeed()); 227 cfsetospeed(&tty, modemspeed());
228 cfsetispeed(&tty, modemspeed()); 228 cfsetispeed(&tty, modemspeed());
229 229
230 tcdrain(modemfd); 230 tcdrain(modemfd);
231 231
232 if(tcsetattr(modemfd, TCSANOW, &tty) < 0){ 232 if(tcsetattr(modemfd, TCSANOW, &tty) < 0){
233 errmsg = i18n("The modem is busy."); 233 errmsg = i18n("The modem is busy.");
234 ::close(modemfd); 234 ::close(modemfd);
235 modemfd=-1; 235 modemfd=-1;
236 return false; 236 return false;
237 } 237 }
@@ -318,154 +318,154 @@ void Modem::flush() {
318 char c; 318 char c;
319 while(read(modemfd, &c, 1) == 1); 319 while(read(modemfd, &c, 1) == 1);
320} 320}
321 321
322 322
323bool Modem::writeChar(unsigned char c) { 323bool Modem::writeChar(unsigned char c) {
324 int s; 324 int s;
325 do { 325 do {
326 s = write(modemfd, &c, 1); 326 s = write(modemfd, &c, 1);
327 if (s < 0) { 327 if (s < 0) {
328 qError( "write() in Modem::writeChar failed" ); 328 qError( "write() in Modem::writeChar failed" );
329 return false; 329 return false;
330 } 330 }
331 } while(s == 0); 331 } while(s == 0);
332 332
333 return true; 333 return true;
334} 334}
335 335
336 336
337bool Modem::writeLine(const char *buf) { 337bool 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';
349 b[len++]='\n'; 349 b[len++]='\n';
350 } 350 }
351 int l = len; 351 int l = len;
352 while(l) { 352 while(l) {
353 int wr = write(modemfd, &b[len-l], l); 353 int wr = write(modemfd, &b[len-l], l);
354 if(wr < 0) { 354 if(wr < 0) {
355 // TODO do something meaningful with the error code (or ignore it 355 // TODO do something meaningful with the error code (or ignore it
356 qError( "write() in Modem::writeLine failed" ); 356 qError( "write() in Modem::writeLine failed" );
357 delete[] b; 357 delete[] b;
358 return false; 358 return false;
359 } 359 }
360 l -= wr; 360 l -= wr;
361 } 361 }
362 delete[] b; 362 delete[] b;
363 return true; 363 return true;
364} 364}
365 365
366 366
367bool Modem::hangup() { 367bool Modem::hangup() {
368 // this should really get the modem to hang up and go into command mode 368 // this should really get the modem to hang up and go into command mode
369 // If anyone sees a fault in the following please let me know, since 369 // If anyone sees a fault in the following please let me know, since
370 // this is probably the most imporant snippet of code in the whole of 370 // this is probably the most imporant snippet of code in the whole of
371 // kppp. If people complain about kppp being stuck, this piece of code 371 // kppp. If people complain about kppp being stuck, this piece of code
372 // is most likely the reason. 372 // is most likely the reason.
373 struct termios temptty; 373 struct termios temptty;
374 374
375 if(modemfd >= 0) { 375 if(modemfd >= 0) {
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);
391 391
392 tcsendbreak(modemfd, 0); 392 tcsendbreak(modemfd, 0);
393 393
394 alarm(0); 394 alarm(0);
395 signal(SIGALRM, SIG_IGN); 395 signal(SIGALRM, SIG_IGN);
396 } else { 396 } else {
397 // we reach this point if the alarm handler got called 397 // we reach this point if the alarm handler got called
398 closetty(); 398 closetty();
399 close(modemfd); 399 close(modemfd);
400 modemfd = -1; 400 modemfd = -1;
401 errmsg = i18n("The modem does not respond."); 401 errmsg = i18n("The modem does not respond.");
402 return false; 402 return false;
403 } 403 }
404 404
405#ifndef __svr4__ // drops DTR but doesn't set it afterwards again. not good for init. 405#ifndef __svr4__ // drops DTR but doesn't set it afterwards again. not good for init.
406 tcgetattr(modemfd, &temptty); 406 tcgetattr(modemfd, &temptty);
407 cfsetospeed(&temptty, B0); 407 cfsetospeed(&temptty, B0);
408 cfsetispeed(&temptty, B0); 408 cfsetispeed(&temptty, B0);
409 tcsetattr(modemfd, TCSAFLUSH, &temptty); 409 tcsetattr(modemfd, TCSAFLUSH, &temptty);
410#else 410#else
411 int modemstat; 411 int modemstat;
412 ioctl(modemfd, TIOCMGET, &modemstat); 412 ioctl(modemfd, TIOCMGET, &modemstat);
413 modemstat &= ~TIOCM_DTR; 413 modemstat &= ~TIOCM_DTR;
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;
427 } else 427 } else
428 return false; 428 return false;
429} 429}
430 430
431 431
432void Modem::escape_to_command_mode() { 432void Modem::escape_to_command_mode() {
433 // Send Properly bracketed escape code to put the modem back into command state. 433 // Send Properly bracketed escape code to put the modem back into command state.
434 // A modem will accept AT commands only when it is in command state. 434 // A modem will accept AT commands only when it is in command state.
435 // When a modem sends the host the CONNECT string, that signals 435 // When a modem sends the host the CONNECT string, that signals
436 // that the modem is now in the connect state (no long accepts AT commands.) 436 // that the modem is now in the connect state (no long accepts AT commands.)
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
453const QString Modem::modemMessage() { 453const QString Modem::modemMessage() {
454 return errmsg; 454 return errmsg;
455} 455}
456 456
457 457
458QString Modem::parseModemSpeed(const QString &s) { 458QString Modem::parseModemSpeed(const QString &s) {
459 // this is a small (and bad) parser for modem speeds 459 // this is a small (and bad) parser for modem speeds
460 int rx = -1; 460 int rx = -1;
461 int tx = -1; 461 int tx = -1;
462 int i; 462 int i;
463 QString result; 463 QString result;
464 464
465 qDebug( "Modem reported result string: %s", s.latin1()); 465 qDebug( "Modem reported result string: %s", s.latin1());
466 466
467 const int RXMAX = 7; 467 const int RXMAX = 7;
468 const int TXMAX = 2; 468 const int TXMAX = 2;
469 QRegExp rrx[RXMAX] = { 469 QRegExp rrx[RXMAX] = {
470 QRegExp("[0-9]+[:/ ]RX", false), 470 QRegExp("[0-9]+[:/ ]RX", false),
471 QRegExp("[0-9]+RX", false), 471 QRegExp("[0-9]+RX", false),
@@ -539,89 +539,89 @@ QString Modem::parseModemSpeed(const QString &s) {
539 } 539 }
540 } 540 }
541 541
542 if(rx == -1 && tx == -1) 542 if(rx == -1 && tx == -1)
543 result = i18n("Unknown speed"); 543 result = i18n("Unknown speed");
544 else if(tx == -1) 544 else if(tx == -1)
545 result.setNum(rx); 545 result.setNum(rx);
546 else if(rx == -1) // should not happen 546 else if(rx == -1) // should not happen
547 result.setNum(tx); 547 result.setNum(tx);
548 else 548 else
549 result.sprintf("%d/%d", rx, tx); 549 result.sprintf("%d/%d", rx, tx);
550 550
551 qDebug( "The parsed result is: %s", result.latin1()); 551 qDebug( "The parsed result is: %s", result.latin1());
552 552
553 return result; 553 return result;
554} 554}
555 555
556 556
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 )
559int Modem::lockdevice() { 559int 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->
576if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) { 576if ((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
579 char oldlock[33]; // safe 579 char oldlock[33]; // safe
580 int sz = read(fd, &oldlock, 32); 580 int sz = read(fd, &oldlock, 32);
581 close (fd); 581 close (fd);
582 if (sz <= 0) 582 if (sz <= 0)
583 return 1; 583 return 1;
584 oldlock[sz] = '\0'; 584 oldlock[sz] = '\0';
585 585
586 qDebug( "Device is locked by: %s", oldlock); 586 qDebug( "Device is locked by: %s", oldlock);
587 587
588 int oldpid; 588 int oldpid;
589 int match = sscanf(oldlock, "%d", &oldpid); 589 int match = sscanf(oldlock, "%d", &oldpid);
590 590
591 // found a pid in lockfile ? 591 // found a pid in lockfile ?
592 if (match < 1 || oldpid <= 0) 592 if (match < 1 || oldpid <= 0)
593 return 1; 593 return 1;
594 594
595 // check if process exists 595 // check if process exists
596 if (kill((pid_t)oldpid, 0) == 0 || errno != ESRCH) 596 if (kill((pid_t)oldpid, 0) == 0 || errno != ESRCH)
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);
610 modem_is_locked=true; 610 modem_is_locked=true;
611 611
612 return 0; 612 return 0;
613 } 613 }
614 614
615 return -1; 615 return -1;
616 616
617} 617}
618 618
619 619
620// UnLock modem device 620// UnLock modem device
621void Modem::unlockdevice() { 621void Modem::unlockdevice() {
622 if (modem_is_locked) { 622 if (modem_is_locked) {
623 qDebug( "UnLocking Modem Device" ); 623 qDebug( "UnLocking Modem Device" );
624 close(modemfd); 624 close(modemfd);
625 modemfd = -1; 625 modemfd = -1;
626 unlink(lockfile); 626 unlink(lockfile);
627 lockfile[0] = '\0'; 627 lockfile[0] = '\0';