author | josef <josef> | 2002-10-13 14:13:07 (UTC) |
---|---|---|
committer | josef <josef> | 2002-10-13 14:13:07 (UTC) |
commit | f45beb0cf615324c01d09560139174e95eb72e34 (patch) (unidiff) | |
tree | b45119071a49bc60c56d0465648f743d61f374ef | |
parent | 68c37a3412ef4609ba0209318ef2b06f7dd1aaf1 (diff) | |
download | opie-f45beb0cf615324c01d09560139174e95eb72e34.zip opie-f45beb0cf615324c01d09560139174e95eb72e34.tar.gz opie-f45beb0cf615324c01d09560139174e95eb72e34.tar.bz2 |
- first stub for modem dialer widget
- this is not yet used in opie-console; to do so, the modem-specific profile
part (AT commands [atconfigdialog.cpp] and dial options [dialdialog.cpp])
should be used
-rw-r--r-- | noncore/apps/opie-console/dialer.cpp | 106 | ||||
-rw-r--r-- | noncore/apps/opie-console/dialer.h | 42 |
2 files changed, 148 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/dialer.cpp b/noncore/apps/opie-console/dialer.cpp new file mode 100644 index 0000000..f6758ed --- a/dev/null +++ b/noncore/apps/opie-console/dialer.cpp | |||
@@ -0,0 +1,106 @@ | |||
1 | #include "dialer.h" | ||
2 | |||
3 | #include <qlayout.h> | ||
4 | #include <qprogressbar.h> | ||
5 | #include <qlabel.h> | ||
6 | #include <qpushbutton.h> | ||
7 | #include <qapp.h> | ||
8 | |||
9 | Dialer::Dialer(const QString& number, QWidget *parent, const char *name) | ||
10 | : QDialog(parent, name, true) | ||
11 | { | ||
12 | QVBoxLayout *vbox; | ||
13 | QLabel *desc; | ||
14 | |||
15 | desc = new QLabel(QObject::tr("Dialing number: %1").arg(number), this); | ||
16 | progress = new QProgressBar(this); | ||
17 | status = new QLabel("", this); | ||
18 | status->setFrameStyle(QFrame::Panel | QFrame::Sunken); | ||
19 | cancel = new QPushButton(QObject::tr("Cancel"), this); | ||
20 | |||
21 | vbox = new QVBoxLayout(this, 2); | ||
22 | vbox->add(desc); | ||
23 | vbox->add(progress); | ||
24 | vbox->add(status); | ||
25 | vbox->add(cancel); | ||
26 | |||
27 | reset(); | ||
28 | |||
29 | connect(cancel, SIGNAL(clicked()), SLOT(slotCancel())); | ||
30 | |||
31 | show(); | ||
32 | |||
33 | dial(number); | ||
34 | } | ||
35 | |||
36 | Dialer::~Dialer() | ||
37 | { | ||
38 | } | ||
39 | |||
40 | void Dialer::slotCancel() | ||
41 | { | ||
42 | if(state != state_online) reset(); | ||
43 | close(); | ||
44 | } | ||
45 | |||
46 | void Dialer::reset() | ||
47 | { | ||
48 | switchState(state_init); | ||
49 | } | ||
50 | |||
51 | void Dialer::dial(const QString& number) | ||
52 | { | ||
53 | send("ATZ"); | ||
54 | QString response = receive(); | ||
55 | |||
56 | switchState(state_options); | ||
57 | |||
58 | send("ATM0L0"); | ||
59 | QString response2 = receive(); | ||
60 | |||
61 | switchState(state_dialing); | ||
62 | |||
63 | send(QString("ATDT %1").arg(number)); | ||
64 | QString response3 = receive(); | ||
65 | |||
66 | switchState(state_online); | ||
67 | } | ||
68 | |||
69 | void Dialer::send(const QString& msg) | ||
70 | { | ||
71 | |||
72 | } | ||
73 | |||
74 | QString Dialer::receive() | ||
75 | { | ||
76 | for(int i = 0; i < 200000; i++) | ||
77 | qApp->processEvents(); | ||
78 | return QString::null; | ||
79 | } | ||
80 | |||
81 | void Dialer::switchState(int newstate) | ||
82 | { | ||
83 | state = newstate; | ||
84 | |||
85 | switch(state) | ||
86 | { | ||
87 | case state_init: | ||
88 | status->setText(QObject::tr("Initializing...")); | ||
89 | progress->setProgress(10); | ||
90 | break; | ||
91 | case state_options: | ||
92 | status->setText(QObject::tr("Reset speakers")); | ||
93 | progress->setProgress(20); | ||
94 | break; | ||
95 | case state_dialing: | ||
96 | status->setText(QObject::tr("Dial number")); | ||
97 | progress->setProgress(30); | ||
98 | break; | ||
99 | case state_online: | ||
100 | status->setText(QObject::tr("Connection established")); | ||
101 | progress->setProgress(100); | ||
102 | cancel->setText(QObject::tr("Dismiss")); | ||
103 | break; | ||
104 | } | ||
105 | } | ||
106 | |||
diff --git a/noncore/apps/opie-console/dialer.h b/noncore/apps/opie-console/dialer.h new file mode 100644 index 0000000..f07f110 --- a/dev/null +++ b/noncore/apps/opie-console/dialer.h | |||
@@ -0,0 +1,42 @@ | |||
1 | #ifndef DIALER_H | ||
2 | #define DIALER_H | ||
3 | |||
4 | #include <qdialog.h> | ||
5 | |||
6 | class QLabel; | ||
7 | class QProgressBar; | ||
8 | |||
9 | class Dialer : public QDialog | ||
10 | { | ||
11 | Q_OBJECT | ||
12 | public: | ||
13 | Dialer(const QString& number, QWidget *parent = NULL, const char *name = NULL); | ||
14 | ~Dialer(); | ||
15 | |||
16 | public slots: | ||
17 | void slotCancel(); | ||
18 | |||
19 | private: | ||
20 | void switchState(int newstate); | ||
21 | void reset(); | ||
22 | void dial(const QString& number); | ||
23 | |||
24 | void send(const QString& msg); | ||
25 | QString receive(); | ||
26 | |||
27 | enum States | ||
28 | { | ||
29 | state_init, | ||
30 | state_options, | ||
31 | state_dialing, | ||
32 | state_online | ||
33 | }; | ||
34 | |||
35 | QLabel *status; | ||
36 | QProgressBar *progress; | ||
37 | QPushButton *cancel; | ||
38 | int state; | ||
39 | }; | ||
40 | |||
41 | #endif | ||
42 | |||