summaryrefslogtreecommitdiff
path: root/noncore
authorjosef <josef>2002-10-17 21:32:37 (UTC)
committer josef <josef>2002-10-17 21:32:37 (UTC)
commit667e17b43b6de0bfce7ab83cb132a0f454a428f0 (patch) (side-by-side diff)
tree2dbc5bf1e83f7961845b847e92fce61e428f8512 /noncore
parent1acda09af779926cc0756d5e5cdf4a67b9dece98 (diff)
downloadopie-667e17b43b6de0bfce7ab83cb132a0f454a428f0.zip
opie-667e17b43b6de0bfce7ab83cb132a0f454a428f0.tar.gz
opie-667e17b43b6de0bfce7ab83cb132a0f454a428f0.tar.bz2
- make modem dialup widget really work
- still todo: communication after dialing number, and error checks
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/dialer.cpp73
-rw-r--r--noncore/apps/opie-console/dialer.h3
-rw-r--r--noncore/apps/opie-console/io_modem.cpp2
3 files changed, 64 insertions, 14 deletions
diff --git a/noncore/apps/opie-console/dialer.cpp b/noncore/apps/opie-console/dialer.cpp
index 89a0e8d..10c16ef 100644
--- a/noncore/apps/opie-console/dialer.cpp
+++ b/noncore/apps/opie-console/dialer.cpp
@@ -8,2 +8,3 @@
#include <qtimer.h>
+#include <qmessagebox.h>
@@ -11,2 +12,4 @@
#include <string.h>
+#include <fcntl.h>
+#include <errno.h>
@@ -46,4 +49,4 @@
-Dialer::Dialer(const Profile& profile, QWidget *parent, const char *name)
-: QDialog(parent, name, true), m_profile(profile)
+Dialer::Dialer(const Profile& profile, int fd, QWidget *parent, const char *name)
+: QDialog(parent, name, true), m_fd(fd), m_profile(profile)
{
@@ -52,4 +55,10 @@ Dialer::Dialer(const Profile& profile, QWidget *parent, const char *name)
+ //m_profile.writeEntry("InitString", "ATZ");
+ //m_profile.writeEntry("DialPrefix1", "ATDT");
+ //m_profile.writeEntry("Termination", "\n");
+
usercancel = 0;
+ fcntl(m_fd, F_SETFL, O_NONBLOCK);
+
desc = new QLabel(QObject::tr("Dialing number: %1").arg(m_profile.readEntry("Number")), this);
@@ -94,3 +103,3 @@ void Dialer::slotAutostart()
{
- state = state_preinit;
+ //state = state_preinit;
dial(m_profile.readEntry("Number"));
@@ -104,2 +113,3 @@ void Dialer::dial(const QString& number)
{
+ state = state_preinit;
trydial(number);
@@ -120,4 +130,5 @@ void Dialer::trydial(const QString& number)
switchState(state_preinit);
- // ...
- QString response = receive();
+ send("+++ATH");
+ send("");
+ //QString response = receive();
}
@@ -127,5 +138,7 @@ void Dialer::trydial(const QString& number)
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();
}
@@ -138,2 +151,4 @@ void Dialer::trydial(const QString& number)
QString response3 = receive();
+ if(!response3.contains("\nOK\r"))
+ reset();
}
@@ -146,2 +161,4 @@ void Dialer::trydial(const QString& number)
QString response4 = receive();
+ if(!response4.contains("\nOK\r"))
+ reset();
}
@@ -152,4 +169,12 @@ void Dialer::trydial(const QString& 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("\nOK\r"))
+ {
+ QMessageBox::warning(this,
+ QObject::tr("Failure"),
+ QObject::tr("Dialing the number failed."));
+ slotCancel();
+ }
}
@@ -168,3 +193,6 @@ void Dialer::send(const QString& msg)
- termination = m_profile.readEntry("Termination");
+qWarning("Sending: '%s'", m.latin1());
+
+ termination = "\r";
+ //termination = m_profile.readEntry("Termination");
if(termination == "\n") m = m + "\n";
@@ -173,3 +201,3 @@ void Dialer::send(const QString& msg)
- bytes = write(0, m.local8Bit(), strlen(m.local8Bit()));
+ bytes = ::write(m_fd, m.local8Bit(), strlen(m.local8Bit()));
if(bytes < 0)
@@ -182,4 +210,25 @@ QString Dialer::receive()
{
- for(int i = 0; i < 200000;i++)
- qApp->processEvents();
+ char buffer[1024];
+ int ret;
+
+ while(1)
+ {
+ ret = ::read(m_fd, buffer, sizeof(buffer));
+
+ if(ret > 0)
+ {
+ for(int i = 0; i < ret; i++)
+ buffer[i] = buffer[i] & 0x7F;
+ buffer[ret] = 0;
+ qWarning("Receiving: '%s'", buffer);
+ return QString(buffer);
+ }
+ else if(ret < 0)
+ {
+ if(errno != EAGAIN) reset();
+ }
+ }
+
+ //for(int i = 0; i < 200000;i++)
+ // qApp->processEvents();
return QString::null;
diff --git a/noncore/apps/opie-console/dialer.h b/noncore/apps/opie-console/dialer.h
index 09cc5ca..4011880 100644
--- a/noncore/apps/opie-console/dialer.h
+++ b/noncore/apps/opie-console/dialer.h
@@ -14,3 +14,3 @@ class Dialer : public QDialog
public:
- Dialer(const Profile& profile, QWidget *parent = NULL, const char *name = NULL);
+ Dialer(const Profile& profile, int fd, QWidget *parent = NULL, const char *name = NULL);
~Dialer();
@@ -47,2 +47,3 @@ class Dialer : public QDialog
const Profile& m_profile;
+ int m_fd;
};
diff --git a/noncore/apps/opie-console/io_modem.cpp b/noncore/apps/opie-console/io_modem.cpp
index 41f553b..c04aad1 100644
--- a/noncore/apps/opie-console/io_modem.cpp
+++ b/noncore/apps/opie-console/io_modem.cpp
@@ -26,3 +26,3 @@ bool IOModem::open() {
- Dialer d(m_profile);
+ Dialer d(m_profile, rawIO());