summaryrefslogtreecommitdiff
path: root/noncore
authorjosef <josef>2002-10-13 14:13:07 (UTC)
committer josef <josef>2002-10-13 14:13:07 (UTC)
commitf45beb0cf615324c01d09560139174e95eb72e34 (patch) (side-by-side diff)
treeb45119071a49bc60c56d0465648f743d61f374ef /noncore
parent68c37a3412ef4609ba0209318ef2b06f7dd1aaf1 (diff)
downloadopie-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
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/dialer.cpp106
-rw-r--r--noncore/apps/opie-console/dialer.h42
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 @@
+#include "dialer.h"
+
+#include <qlayout.h>
+#include <qprogressbar.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
+#include <qapp.h>
+
+Dialer::Dialer(const QString& number, QWidget *parent, const char *name)
+: QDialog(parent, name, true)
+{
+ QVBoxLayout *vbox;
+ QLabel *desc;
+
+ desc = new QLabel(QObject::tr("Dialing number: %1").arg(number), this);
+ progress = new QProgressBar(this);
+ status = new QLabel("", this);
+ status->setFrameStyle(QFrame::Panel | QFrame::Sunken);
+ cancel = new QPushButton(QObject::tr("Cancel"), this);
+
+ vbox = new QVBoxLayout(this, 2);
+ vbox->add(desc);
+ vbox->add(progress);
+ vbox->add(status);
+ vbox->add(cancel);
+
+ reset();
+
+ connect(cancel, SIGNAL(clicked()), SLOT(slotCancel()));
+
+ show();
+
+ dial(number);
+}
+
+Dialer::~Dialer()
+{
+}
+
+void Dialer::slotCancel()
+{
+ if(state != state_online) reset();
+ close();
+}
+
+void Dialer::reset()
+{
+ switchState(state_init);
+}
+
+void Dialer::dial(const QString& number)
+{
+ send("ATZ");
+ QString response = receive();
+
+ switchState(state_options);
+
+ send("ATM0L0");
+ QString response2 = receive();
+
+ switchState(state_dialing);
+
+ send(QString("ATDT %1").arg(number));
+ QString response3 = receive();
+
+ switchState(state_online);
+}
+
+void Dialer::send(const QString& msg)
+{
+
+}
+
+QString Dialer::receive()
+{
+ for(int i = 0; i < 200000; i++)
+ qApp->processEvents();
+ return QString::null;
+}
+
+void Dialer::switchState(int newstate)
+{
+ state = newstate;
+
+ switch(state)
+ {
+ case state_init:
+ status->setText(QObject::tr("Initializing..."));
+ progress->setProgress(10);
+ break;
+ case state_options:
+ status->setText(QObject::tr("Reset speakers"));
+ progress->setProgress(20);
+ break;
+ case state_dialing:
+ status->setText(QObject::tr("Dial number"));
+ progress->setProgress(30);
+ break;
+ case state_online:
+ status->setText(QObject::tr("Connection established"));
+ progress->setProgress(100);
+ cancel->setText(QObject::tr("Dismiss"));
+ break;
+ }
+}
+
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 @@
+#ifndef DIALER_H
+#define DIALER_H
+
+#include <qdialog.h>
+
+class QLabel;
+class QProgressBar;
+
+class Dialer : public QDialog
+{
+ Q_OBJECT
+ public:
+ Dialer(const QString& number, QWidget *parent = NULL, const char *name = NULL);
+ ~Dialer();
+
+ public slots:
+ void slotCancel();
+
+ private:
+ void switchState(int newstate);
+ void reset();
+ void dial(const QString& number);
+
+ void send(const QString& msg);
+ QString receive();
+
+ enum States
+ {
+ state_init,
+ state_options,
+ state_dialing,
+ state_online
+ };
+
+ QLabel *status;
+ QProgressBar *progress;
+ QPushButton *cancel;
+ int state;
+};
+
+#endif
+