summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/dialer.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-console/dialer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/dialer.cpp50
1 files changed, 44 insertions, 6 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
@@ -4,12 +4,15 @@
4#include <qprogressbar.h> 4#include <qprogressbar.h>
5#include <qlabel.h> 5#include <qlabel.h>
6#include <qpushbutton.h> 6#include <qpushbutton.h>
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,
13// | | | we stop dialing immediately. 16// | | | we stop dialing immediately.
14// v | | 17// v | |
15// (options) ----+ | Following the state machine is necessary 18// (options) ----+ | Following the state machine is necessary
@@ -19,22 +22,41 @@
19// | ^ | 22// | ^ |
20// v | | 23// v | |
21// (online) --+ | 24// (online) --+ |
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);
38 cancel = new QPushButton(QObject::tr("Cancel"), this); 60 cancel = new QPushButton(QObject::tr("Cancel"), this);
39 61
40 vbox = new QVBoxLayout(this, 2); 62 vbox = new QVBoxLayout(this, 2);
@@ -53,26 +75,29 @@ Dialer::Dialer(const QString& number, QWidget *parent, const char *name)
53Dialer::~Dialer() 75Dialer::~Dialer()
54{ 76{
55} 77}
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)
76{ 101{
77 while(state != state_online) 102 while(state != state_online)
78 { 103 {
@@ -134,13 +159,26 @@ void Dialer::trydial(const QString& number)
134 switchState(state_online); 159 switchState(state_online);
135 } 160 }
136} 161}
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()
144{ 182{
145 for(int i = 0; i < 200000;i++) 183 for(int i = 0; i < 200000;i++)
146 qApp->processEvents(); 184 qApp->processEvents();