summaryrefslogtreecommitdiff
authorjosef <josef>2002-10-13 15:52:00 (UTC)
committer josef <josef>2002-10-13 15:52:00 (UTC)
commitcb816d85c54242f8958ff77fba334b43be0dcb3d (patch) (unidiff)
tree6764b80acf8789c410cdc59cb308f3f91fcd9083
parent6a9726437a59cf3b18bf57d6e20fb2dfaaa2fc34 (diff)
downloadopie-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)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/dialer.cpp50
-rw-r--r--noncore/apps/opie-console/dialer.h6
-rw-r--r--noncore/apps/opie-console/io_modem.cpp13
-rw-r--r--noncore/apps/opie-console/io_modem.h1
-rw-r--r--noncore/apps/opie-console/opie-console.pro6
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
@@ -7,6 +7,9 @@
7#include <qapp.h> 7#include <qapp.h>
8#include <qtimer.h> 8#include <qtimer.h>
9 9
10#include <unistd.h>
11#include <string.h>
12
10// State machine: | When an error occurs, we don't have to 13// State machine: | When an error occurs, we don't have to
11// | reset everything. 14// | reset everything.
12// (init) <------+ | But if the user wants to reset, 15// (init) <------+ | But if the user wants to reset,
@@ -22,16 +25,35 @@
22// | | 25// | |
23// v | 26// v |
24 27
25Dialer::Dialer(const QString& number, QWidget *parent, const char *name) 28
29// from atconfigdialog
30//initStringLine->setText( config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ) );
31//resetStringLine->setText( config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ) );
32//dialPref1Line->setText( config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ) );
33//dialSuf1Line->setText( config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ) );
34//dialPref2Line->setText( config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ) );
35//dialSuf2Line->setText( config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ) );
36//dialPref3Line->setText( config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ) );
37//dialSuf3Line->setText( config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ) );
38//connectLine->setText( config.readEntry("DefaultConnect" MODEM_DEFAULT_CONNECT_STRING ) );
39//hangupLine->setText( config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) );
40
41// from modemconfigwidget
42//int rad_flow = prof.readNumEntry("Flow");
43//int rad_parity = prof.readNumEntry("Parity");
44//int speed = prof.readNumEntry("Speed");
45//QString number = prof.readEntry("Number");
46
47Dialer::Dialer(const Profile& profile, QWidget *parent, const char *name)
26: QDialog(parent, name, true) 48: QDialog(parent, name, true)
27{ 49{
28 QVBoxLayout *vbox; 50 QVBoxLayout *vbox;
29 QLabel *desc; 51 QLabel *desc;
30 52
31 usercancel = 0; 53 usercancel = 0;
32 m_number = number; 54 m_profile = profile;
33 55
34 desc = new QLabel(QObject::tr("Dialing number: %1").arg(number), this); 56 desc = new QLabel(QObject::tr("Dialing number: %1").arg(m_profile.readEntry("Number")), this);
35 progress = new QProgressBar(this); 57 progress = new QProgressBar(this);
36 status = new QLabel("", this); 58 status = new QLabel("", this);
37 status->setFrameStyle(QFrame::Panel | QFrame::Sunken); 59 status->setFrameStyle(QFrame::Panel | QFrame::Sunken);
@@ -56,20 +78,23 @@ Dialer::~Dialer()
56 78
57void Dialer::slotCancel() 79void Dialer::slotCancel()
58{ 80{
59 if(state != state_online) reset(); 81 if(state != state_online)
82 {
83 usercancel = 1;
84 reset();
85 }
60 else accept(); 86 else accept();
61} 87}
62 88
63void Dialer::reset() 89void Dialer::reset()
64{ 90{
65 switchState(state_cancel); 91 switchState(state_cancel);
66 usercancel = 1;
67} 92}
68 93
69void Dialer::slotAutostart() 94void Dialer::slotAutostart()
70{ 95{
71 state = state_preinit; 96 state = state_preinit;
72 dial(m_number); 97 dial(m_profile.readEntry("Number"));
73} 98}
74 99
75void Dialer::dial(const QString& number) 100void Dialer::dial(const QString& number)
@@ -137,7 +162,20 @@ void Dialer::trydial(const QString& number)
137 162
138void Dialer::send(const QString& msg) 163void Dialer::send(const QString& msg)
139{ 164{
165 QString m = msg;
166 int bytes;
167 QString termination;
140 168
169 termination = m_profile.readEntry("Termination");
170 if(termination == "\n") m = m + "\n";
171 else if(termination == "\r") m = m + "\r";
172 else m = m + "\r\n";
173
174 bytes = write(0, m.local8Bit(), strlen(m.local8Bit()));
175 if(bytes < 0)
176 {
177 reset();
178 }
141} 179}
142 180
143QString Dialer::receive() 181QString 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
@@ -3,6 +3,8 @@
3 3
4#include <qdialog.h> 4#include <qdialog.h>
5 5
6#include "profile.h"
7
6class QLabel; 8class QLabel;
7class QProgressBar; 9class QProgressBar;
8 10
@@ -10,7 +12,7 @@ class Dialer : public QDialog
10{ 12{
11 Q_OBJECT 13 Q_OBJECT
12 public: 14 public:
13 Dialer(const QString& number, QWidget *parent = NULL, const char *name = NULL); 15 Dialer(const Profile& profile, QWidget *parent = NULL, const char *name = NULL);
14 ~Dialer(); 16 ~Dialer();
15 17
16 public slots: 18 public slots:
@@ -42,7 +44,7 @@ class Dialer : public QDialog
42 QPushButton *cancel; 44 QPushButton *cancel;
43 int state; 45 int state;
44 int usercancel; 46 int usercancel;
45 QString m_number; 47 Profile m_profile;
46}; 48};
47 49
48#endif 50#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,8 +1,10 @@
1 1
2#include "io_modem.h" 2#include "io_modem.h"
3 3
4IOModem:IOModem( const Profile &config ) : IOSerial( config ) { 4#include "dialer.h"
5 5
6IOModem:IOModem( const Profile &config ) : IOSerial( config ) {
7 m_config = config;
6} 8}
7 9
8 10
@@ -18,10 +20,15 @@ void IOModem::close() {
18} 20}
19 21
20bool IOModem::open() { 22bool IOModem::open() {
21
22
23 IOSerial::open(); 23 IOSerial::open();
24 24
25 Dialer d(m_profile);
26 int result = d.exec();
27 if(result == QDialog::Accepted)
28 {
29 return true;
30 }
31 else return false;
25} 32}
26 33
27void IOModem::reload( const Profile &config ) { 34void IOModem::reload( const Profile &config ) {
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
@@ -60,6 +60,7 @@ private:
60 m_dialSuf2, dialPref3, m_dialSuf3, m_connect, m_hangup, m_cancel; 60 m_dialSuf2, dialPref3, m_dialSuf3, m_connect, m_hangup, m_cancel;
61 int m_dialTime, m_delayRedial, m_numberTries, m_dtrDropTime, 61 int m_dialTime, m_delayRedial, m_numberTries, m_dtrDropTime,
62 m_bpsDetect, m_dcdLines, m_multiLineUntag; 62 m_bpsDetect, m_dcdLines, m_multiLineUntag;
63 const Profile& m_profile;
63 64
64private slots: 65private slots:
65 void slotExited(OProcess* proc); 66 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
@@ -32,7 +32,8 @@ HEADERS = io_layer.h io_serial.h io_irda.h io_bt.h\
32 emulation_widget.h procctl.h \ 32 emulation_widget.h procctl.h \
33 function_keyboard.h \ 33 function_keyboard.h \
34 receive_layer.h filereceive.h \ 34 receive_layer.h filereceive.h \
35 script.h 35 script.h \
36 dialer.h
36 37
37SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp \ 38SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp \
38 file_layer.cpp filetransfer.cpp \ 39 file_layer.cpp filetransfer.cpp \
@@ -62,7 +63,8 @@ SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp \
62 emulation_widget.cpp default.cpp procctl.cpp \ 63 emulation_widget.cpp default.cpp procctl.cpp \
63 function_keyboard.cpp \ 64 function_keyboard.cpp \
64 receive_layer.cpp filereceive.cpp \ 65 receive_layer.cpp filereceive.cpp \
65 script.cpp 66 script.cpp \
67 dialer.cpp
66 68
67INTERFACES = configurebase.ui editbase.ui 69INTERFACES = configurebase.ui editbase.ui
68INCLUDEPATH += $(OPIEDIR)/include 70INCLUDEPATH += $(OPIEDIR)/include