summaryrefslogtreecommitdiff
authorjosef <josef>2002-10-20 09:48:21 (UTC)
committer josef <josef>2002-10-20 09:48:21 (UTC)
commit940ba90ed4375f79b6a4934d290abf83980b77ad (patch) (side-by-side diff)
treec455e88ce9fe99ef79048e3f228b7f4551652537
parente2694c5aedb3697a373e363cebe72cddb3114a8f (diff)
downloadopie-940ba90ed4375f79b6a4934d290abf83980b77ad.zip
opie-940ba90ed4375f79b6a4934d290abf83980b77ad.tar.gz
opie-940ba90ed4375f79b6a4934d290abf83980b77ad.tar.bz2
Please review!
- change modem default commands because we don't interpret ~ and friends (minicom does AFAIK) - disable unused AT settings for now - when cancelling dialing, and we didn't yet get a single byte from the modem, don't hangup
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/atconfigdialog.cpp16
-rw-r--r--noncore/apps/opie-console/atconfigdialog.h19
-rw-r--r--noncore/apps/opie-console/dialer.cpp37
-rw-r--r--noncore/apps/opie-console/dialer.h1
-rw-r--r--noncore/apps/opie-console/io_modem.h18
5 files changed, 47 insertions, 44 deletions
diff --git a/noncore/apps/opie-console/atconfigdialog.cpp b/noncore/apps/opie-console/atconfigdialog.cpp
index 87a08f6..5c02692 100644
--- a/noncore/apps/opie-console/atconfigdialog.cpp
+++ b/noncore/apps/opie-console/atconfigdialog.cpp
@@ -4,16 +4,17 @@
#include <qlayout.h>
#include <qcombobox.h>
#include <qtabwidget.h>
#include <qlabel.h>
#include <qcombobox.h>
#include <qscrollview.h>
#include "atconfigdialog.h"
+#include "io_modem.h"
ATConfigDialog::ATConfigDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
: QDialog( parent, name, modal, fl ) {
setCaption( tr( "Dialing parameter setup" ) );
@@ -165,16 +166,31 @@ void ATConfigDialog::readConfig( const Profile& config ) {
hangupLine->setText( config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) );
dialTimeSpin->setValue( config.readNumEntry("DialTime", MODEM_DEFAULT_DIAL_TIME ) );
delayRedialSpin->setValue( config.readNumEntry("DelayRedial", MODEM_DEFAULT_DELAY_REDIAL ) );
numberTriesSpin->setValue( config.readNumEntry("NumberTries", MODEM_DEFAULT_NUMBER_TRIES ) );
dtrDropTimeSpin->setValue( config.readNumEntry("DTRDRopTime", MODEM_DEFAULT_DTR_DROP_TIME ) );
bpsDetectBox->setCurrentItem( config.readBoolEntry("BPSDetect", MODEM_DEFAULT_BPS_DETECT ) );
dcdLinesBox->setCurrentItem( config.readBoolEntry("DCDLines", MODEM_DEFAULT_DCD_LINES ) );
multiLineUntagBox->setCurrentItem( config.readBoolEntry("MultiLineUntag", MODEM_DEFAULT_MULTI_LINE_UNTAG ) );
+
+ // Not implemented yet
+ resetStringLine->setEnabled(false);
+ dialSuf1Line->setEnabled(false);
+ dialPref2Line->setEnabled(false);
+ dialSuf2Line->setEnabled(false);
+ dialPref3Line->setEnabled(false);
+ dialSuf3Line->setEnabled(false);
+ dialTimeSpin->setEnabled(false);
+ delayRedialSpin->setEnabled(false);
+ numberTriesSpin->setEnabled(false);
+ dtrDropTimeSpin->setEnabled(false);
+ bpsDetectBox->setEnabled(false);
+ dcdLinesBox->setEnabled(false);
+ multiLineUntagBox->setEnabled(false);
}
void ATConfigDialog::writeConfig( Profile& config ) {
config.writeEntry( "InitString", initStringLine->text() );
config.writeEntry( "ResetString", resetStringLine->text() );
config.writeEntry( "DialPrefix1", dialPref1Line->text() );
config.writeEntry( "DialSuffix1", dialSuf1Line->text() );
diff --git a/noncore/apps/opie-console/atconfigdialog.h b/noncore/apps/opie-console/atconfigdialog.h
index 4dd033b..8cb044e 100644
--- a/noncore/apps/opie-console/atconfigdialog.h
+++ b/noncore/apps/opie-console/atconfigdialog.h
@@ -1,34 +1,15 @@
#ifndef ATCONFIGDIALOG_H
#define ATCONFIGDIALOG_H
#include <qdialog.h>
#include "profile.h"
-#define MODEM_DEFAULT_INIT_STRING "~^M~ATZ^M~"
-#define MODEM_DEFAULT_RESET_STRING "~^M~ATZ^M~"
-#define MODEM_DEFAULT_DIAL_PREFIX1 "ATDT"
-#define MODEM_DEFAULT_DIAL_SUFFIX1 "^M"
-#define MODEM_DEFAULT_DIAL_PREFIX2 "ATDP"
-#define MODEM_DEFAULT_DIAL_SUFFIX2 "^M"
-#define MODEM_DEFAULT_DIAL_PREFIX3 "ATX1DT"
-#define MODEM_DEFAULT_DIAL_SUFFIX3 ";X4D^M"
-#define MODEM_DEFAULT_CONNECT_STRING "CONNECT"
-#define MODEM_DEFAULT_HANGUP_STRING "~~+++~~ATH^M"
-#define MODEM_DEFAULT_CANCEL_STRING "^M"
-#define MODEM_DEFAULT_DIAL_TIME 45
-#define MODEM_DEFAULT_DELAY_REDIAL 2
-#define MODEM_DEFAULT_NUMBER_TRIES 10
-#define MODEM_DEFAULT_DTR_DROP_TIME 1
-#define MODEM_DEFAULT_BPS_DETECT 0 // bool
-#define MODEM_DEFAULT_DCD_LINES 1 //bool
-#define MODEM_DEFAULT_MULTI_LINE_UNTAG 0 // bool
-
class QLineEdit;
class QSpinBox;
class QComboBox;
class ATConfigDialog : public QDialog {
Q_OBJECT
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
@@ -53,16 +53,17 @@ Dialer::Dialer(const Profile& profile, int fd, QWidget *parent, const char *name
QVBoxLayout *vbox;
QLabel *desc;
//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);
status->setFrameStyle(QFrame::Panel | QFrame::Sunken);
cancel = new QPushButton(QObject::tr("Cancel"), this);
@@ -128,29 +129,29 @@ void Dialer::dial(const QString& number)
// modem hangup
trydial(QString::null);
reject();
}
}
void Dialer::trydial(const QString& number)
{
- //if(state != state_cancel)
- //{
- if(state != state_cancel) switchState(state_preinit);
- send("+++ATH");
+ if(state != state_cancel) switchState(state_preinit);
+ 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)
{
switchState(state_options);
@@ -170,20 +171,20 @@ void Dialer::trydial(const QString& number)
if(!response4.contains("\nOK\r"))
reset();
}
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,
QObject::tr("Failure"),
QObject::tr("Dialing the number failed."));
@@ -199,17 +200,17 @@ 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";
bytes = ::write(m_fd, m.local8Bit(), strlen(m.local8Bit()));
@@ -230,32 +231,36 @@ QString Dialer::receive()
{
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("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;
state = newstate;
diff --git a/noncore/apps/opie-console/dialer.h b/noncore/apps/opie-console/dialer.h
index 84444b9..28303f3 100644
--- a/noncore/apps/opie-console/dialer.h
+++ b/noncore/apps/opie-console/dialer.h
@@ -42,12 +42,13 @@ class Dialer : public QDialog
QLabel *status;
QProgressBar *progress;
QPushButton *cancel;
int state;
int usercancel;
const Profile& m_profile;
int m_fd;
+ int cleanshutdown;
};
#endif
diff --git a/noncore/apps/opie-console/io_modem.h b/noncore/apps/opie-console/io_modem.h
index 8453b95..1328706 100644
--- a/noncore/apps/opie-console/io_modem.h
+++ b/noncore/apps/opie-console/io_modem.h
@@ -8,27 +8,27 @@
/* Default values to be used if the profile information is incomplete */
#define MODEM_DEFAULT_DEVICE "/dev/ttyS0"
#define MODEM_DEFAULT_BAUD 9600
#define MODEM_DEFAULT_PARITY 0
#define MODEM_DEFAULT_DBITS 8
#define MODEM_DEFAULT_SBITS 1
#define MODEM_DEFAULT_FLOW 0
-#define MODEM_DEFAULT_INIT_STRING "~^M~ATZ^M~"
-#define MODEM_DEFAULT_RESET_STRING "~^M~ATZ^M~"
+#define MODEM_DEFAULT_INIT_STRING "ATZ"
+#define MODEM_DEFAULT_RESET_STRING "ATZ~"
#define MODEM_DEFAULT_DIAL_PREFIX1 "ATDT"
-#define MODEM_DEFAULT_DIAL_SUFFIX1 "^M"
-#define MODEM_DEFAULT_DIAL_PREFIX2 "ATDP"
-#define MODEM_DEFAULT_DIAL_SUFFIX2 "^M"
-#define MODEM_DEFAULT_DIAL_PREFIX3 "ATX1DT"
-#define MODEM_DEFAULT_DIAL_SUFFIX3 ";X4D^M"
+#define MODEM_DEFAULT_DIAL_SUFFIX1 ""
+#define MODEM_DEFAULT_DIAL_PREFIX2 ""
+#define MODEM_DEFAULT_DIAL_SUFFIX2 ""
+#define MODEM_DEFAULT_DIAL_PREFIX3 ""
+#define MODEM_DEFAULT_DIAL_SUFFIX3 ""
#define MODEM_DEFAULT_CONNECT_STRING "CONNECT"
-#define MODEM_DEFAULT_HANGUP_STRING "~~+++~~ATH^M"
-#define MODEM_DEFAULT_CANCEL_STRING "^M"
+#define MODEM_DEFAULT_HANGUP_STRING "+++ATH"
+#define MODEM_DEFAULT_CANCEL_STRING ""
#define MODEM_DEFAULT_DIAL_TIME 45
#define MODEM_DEFAULT_DELAY_REDIAL 2
#define MODEM_DEFAULT_NUMBER_TRIES 10
#define MODEM_DEFAULT_DTR_DROP_TIME 1
#define MODEM_DEFAULT_BPS_DETECT 0 // bool
#define MODEM_DEFAULT_DCD_LINES 1 //bool
#define MODEM_DEFAULT_MULTI_LINE_UNTAG 0 // bool