From f45beb0cf615324c01d09560139174e95eb72e34 Mon Sep 17 00:00:00 2001 From: josef Date: Sun, 13 Oct 2002 14:13:07 +0000 Subject: - 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 --- (limited to 'noncore/apps/opie-console') 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 +#include +#include +#include +#include + +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 + +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 + -- cgit v0.9.0.2