author | josef <josef> | 2002-10-13 15:52:00 (UTC) |
---|---|---|
committer | josef <josef> | 2002-10-13 15:52:00 (UTC) |
commit | cb816d85c54242f8958ff77fba334b43be0dcb3d (patch) (side-by-side diff) | |
tree | 6764b80acf8789c410cdc59cb308f3f91fcd9083 | |
parent | 6a9726437a59cf3b18bf57d6e20fb2dfaaa2fc34 (diff) | |
download | opie-cb816d85c54242f8958ff77fba334b43be0dcb3d.zip opie-cb816d85c54242f8958ff77fba334b43be0dcb3d.tar.gz opie-cb816d85c54242f8958ff77fba334b43be0dcb3d.tar.bz2 |
- make dialer accessible transparently when opening a modem session
- implement sending data (currently written to stdout for debug purpose)
-rw-r--r-- | noncore/apps/opie-console/dialer.cpp | 50 | ||||
-rw-r--r-- | noncore/apps/opie-console/dialer.h | 6 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_modem.cpp | 13 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_modem.h | 1 | ||||
-rw-r--r-- | noncore/apps/opie-console/opie-console.pro | 6 |
5 files changed, 63 insertions, 13 deletions
diff --git a/noncore/apps/opie-console/dialer.cpp b/noncore/apps/opie-console/dialer.cpp index 8589d14..d20965a 100644 --- a/noncore/apps/opie-console/dialer.cpp +++ b/noncore/apps/opie-console/dialer.cpp @@ -6,8 +6,11 @@ #include <qpushbutton.h> #include <qapp.h> #include <qtimer.h> +#include <unistd.h> +#include <string.h> + // State machine: | When an error occurs, we don't have to // | reset everything. // (init) <------+ | But if the user wants to reset, // | | | we stop dialing immediately. @@ -21,18 +24,37 @@ // (online) --+ | // | | // v | -Dialer::Dialer(const QString& number, QWidget *parent, const char *name) + +// from atconfigdialog +//initStringLine->setText( config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ) ); +//resetStringLine->setText( config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ) ); +//dialPref1Line->setText( config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ) ); +//dialSuf1Line->setText( config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); +//dialPref2Line->setText( config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ) ); +//dialSuf2Line->setText( config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); +//dialPref3Line->setText( config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ) ); +//dialSuf3Line->setText( config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); +//connectLine->setText( config.readEntry("DefaultConnect" MODEM_DEFAULT_CONNECT_STRING ) ); +//hangupLine->setText( config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) ); + +// from modemconfigwidget +//int rad_flow = prof.readNumEntry("Flow"); +//int rad_parity = prof.readNumEntry("Parity"); +//int speed = prof.readNumEntry("Speed"); +//QString number = prof.readEntry("Number"); + +Dialer::Dialer(const Profile& profile, QWidget *parent, const char *name) : QDialog(parent, name, true) { QVBoxLayout *vbox; QLabel *desc; usercancel = 0; - m_number = number; + m_profile = profile; - desc = new QLabel(QObject::tr("Dialing number: %1").arg(number), this); + 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); @@ -55,22 +77,25 @@ Dialer::~Dialer() } void Dialer::slotCancel() { - if(state != state_online) reset(); + if(state != state_online) + { + usercancel = 1; + reset(); + } else accept(); } void Dialer::reset() { switchState(state_cancel); - usercancel = 1; } void Dialer::slotAutostart() { state = state_preinit; - dial(m_number); + dial(m_profile.readEntry("Number")); } void Dialer::dial(const QString& number) { @@ -136,9 +161,22 @@ void Dialer::trydial(const QString& number) } void Dialer::send(const QString& msg) { + QString m = msg; + int bytes; + QString termination; + + 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(0, m.local8Bit(), strlen(m.local8Bit())); + if(bytes < 0) + { + reset(); + } } QString Dialer::receive() { diff --git a/noncore/apps/opie-console/dialer.h b/noncore/apps/opie-console/dialer.h index 20fb3c3..8c83bb6 100644 --- a/noncore/apps/opie-console/dialer.h +++ b/noncore/apps/opie-console/dialer.h @@ -2,16 +2,18 @@ #define DIALER_H #include <qdialog.h> +#include "profile.h" + class QLabel; class QProgressBar; class Dialer : public QDialog { Q_OBJECT public: - Dialer(const QString& number, QWidget *parent = NULL, const char *name = NULL); + Dialer(const Profile& profile, QWidget *parent = NULL, const char *name = NULL); ~Dialer(); public slots: void slotCancel(); @@ -41,9 +43,9 @@ class Dialer : public QDialog QProgressBar *progress; QPushButton *cancel; int state; int usercancel; - QString m_number; + Profile m_profile; }; #endif diff --git a/noncore/apps/opie-console/io_modem.cpp b/noncore/apps/opie-console/io_modem.cpp index 4d6035d..41febfb 100644 --- a/noncore/apps/opie-console/io_modem.cpp +++ b/noncore/apps/opie-console/io_modem.cpp @@ -1,9 +1,11 @@ #include "io_modem.h" -IOModem:IOModem( const Profile &config ) : IOSerial( config ) { +#include "dialer.h" +IOModem:IOModem( const Profile &config ) : IOSerial( config ) { + m_config = config; } IOModem::~IOModem() { @@ -17,12 +19,17 @@ void IOModem::close() { } bool IOModem::open() { - - IOSerial::open(); + Dialer d(m_profile); + int result = d.exec(); + if(result == QDialog::Accepted) + { + return true; + } + else return false; } void IOModem::reload( const Profile &config ) { m_device = config.readEntry("Device", MODEM_DEFAULT_DEVICE); diff --git a/noncore/apps/opie-console/io_modem.h b/noncore/apps/opie-console/io_modem.h index f155eb1..6d44349 100644 --- a/noncore/apps/opie-console/io_modem.h +++ b/noncore/apps/opie-console/io_modem.h @@ -59,8 +59,9 @@ private: QString m_initString, m_resetString, m_dialPref1, m_dialSuf1, m_dialPref2, m_dialSuf2, dialPref3, m_dialSuf3, m_connect, m_hangup, m_cancel; int m_dialTime, m_delayRedial, m_numberTries, m_dtrDropTime, m_bpsDetect, m_dcdLines, m_multiLineUntag; + const Profile& m_profile; private slots: void slotExited(OProcess* proc); diff --git a/noncore/apps/opie-console/opie-console.pro b/noncore/apps/opie-console/opie-console.pro index 0b4676b..ef6bc21 100644 --- a/noncore/apps/opie-console/opie-console.pro +++ b/noncore/apps/opie-console/opie-console.pro @@ -31,9 +31,10 @@ HEADERS = io_layer.h io_serial.h io_irda.h io_bt.h\ atconfigdialog.h dialdialog.h \ emulation_widget.h procctl.h \ function_keyboard.h \ receive_layer.h filereceive.h \ - script.h + script.h \ + dialer.h SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp \ file_layer.cpp filetransfer.cpp \ main.cpp \ @@ -61,9 +62,10 @@ SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp \ atconfigdialog.cpp dialdialog.cpp \ emulation_widget.cpp default.cpp procctl.cpp \ function_keyboard.cpp \ receive_layer.cpp filereceive.cpp \ - script.cpp + script.cpp \ + dialer.cpp INTERFACES = configurebase.ui editbase.ui INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include |