Diffstat (limited to 'noncore/apps/opie-console/dialer.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/dialer.cpp | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/noncore/apps/opie-console/dialer.cpp b/noncore/apps/opie-console/dialer.cpp index 51d4093..d37e406 100644 --- a/noncore/apps/opie-console/dialer.cpp +++ b/noncore/apps/opie-console/dialer.cpp @@ -55,12 +55,13 @@ Dialer::Dialer(const Profile& profile, int fd, QWidget *parent, const char *name //m_profile.writeEntry("InitString", "ATZ"); //m_profile.writeEntry("DialPrefix1", "ATDT"); //m_profile.writeEntry("Termination", "\n"); usercancel = 0; + cleanshutdown = 0; fcntl(m_fd, F_SETFL, O_NONBLOCK); desc = new QLabel(QObject::tr("Dialing number: %1").arg(m_profile.readEntry("Number")), this); progress = new QProgressBar(this); status = new QLabel("", this); @@ -130,25 +131,25 @@ void Dialer::dial(const QString& number) reject(); } } void Dialer::trydial(const QString& number) { - //if(state != state_cancel) - //{ if(state != state_cancel) switchState(state_preinit); - send("+++ATH"); + if(cleanshutdown) + { + send(m_profile.readEntry("HangupString")); + //send("+++ATH"); send(""); - //QString response = receive(); - //} + } if(state != state_cancel) { switchState(state_init); - send("ATZ"); - //send(m_profile.readEntry("InitString")); + //send("ATZ"); + send(m_profile.readEntry("InitString")); QString response2 = receive(); if(!response2.contains("\nOK\r")) reset(); } if(state != state_cancel) @@ -172,16 +173,16 @@ void Dialer::trydial(const QString& number) } if(state != state_cancel) { switchState(state_dialing); - send(QString("ATDT %1").arg(number)); - //send(QString("%1 %2").arg(m_profile.readEntry("DialPrefix1")).arg(number)); + //send(QString("ATDT %1").arg(number)); + send(QString("%1 %2").arg(m_profile.readEntry("DialPrefix1")).arg(number)); QString response5 = receive(); - if(!response5.contains("\nCONNECT")) + if(!response5.contains("\n" + m_profile.readEntry("DefaultConnect"))) { if(response5.contains("BUSY")) switchState(state_dialing); else { QMessageBox::warning(this, @@ -201,13 +202,13 @@ void Dialer::trydial(const QString& number) void Dialer::send(const QString& msg) { QString m = msg; int bytes; QString termination; -qWarning("Sending: '%s'", m.latin1()); + //qWarning("Sending: '%s'", m.latin1()); termination = "\r"; //termination = m_profile.readEntry("Termination"); if(termination == "\n") m = m + "\n"; else if(termination == "\r") m = m + "\r"; else m = m + "\r\n"; @@ -232,28 +233,32 @@ QString Dialer::receive() if(ret > 0) { for(int i = 0; i < ret; i++) buffer[i] = buffer[i] & 0x7F; buffer[ret] = 0; -qWarning("Got: '%s'", buffer); + //qWarning("Got: '%s'", buffer); buf.append(QString(buffer)); if(buf.contains("OK") || buf.contains("ERROR") || buf.contains("CONNECT") || (buf.contains("BUSY"))) { -qWarning("Receiving: '%s'", buf.latin1()); + //qWarning("Receiving: '%s'", buf.latin1()); + cleanshutdown = 1; return buf; } } else if(ret < 0) { if(errno != EAGAIN) reset(); else if(!(counter++ % 100)) qApp->processEvents(); } else if(!(counter++ % 100)) qApp->processEvents(); + + if(usercancel) return QString::null; } + cleanshutdown = 1; return QString::null; } void Dialer::switchState(int newstate) { int oldstate = state; |