From 2314955ff0127a570e25e7e7a10ce4d17a2de0e2 Mon Sep 17 00:00:00 2001 From: dwmw2 Date: Tue, 02 Apr 2002 00:02:59 +0000 Subject: Start of GSM app. Still not decided what to do with gsmlib. Needs icon. --- (limited to 'noncore/unsupported') diff --git a/noncore/unsupported/gsmtool/gsmtool.cpp b/noncore/unsupported/gsmtool/gsmtool.cpp new file mode 100644 index 0000000..14ef368 --- a/dev/null +++ b/noncore/unsupported/gsmtool/gsmtool.cpp @@ -0,0 +1,208 @@ +#include "gsmtool.h" +#include +#include +#include +#include +#include + +#include + +#include +#include + +using namespace gsmlib; + + +/* + * Constructs a GSMTool which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + */ +GSMTool::GSMTool( QWidget* parent, const char* name, WFlags fl ) + : GSMToolBase( parent, name, fl ) +{ + devicelocked = 0; + me = NULL; + port = NULL; + setConnected(FALSE); + /* FIXME: Persistent settings for device/baudrate */ + connect(ConnectButton, SIGNAL(clicked()), this, SLOT(doConnectButton())); + connect(ScanButton, SIGNAL(clicked()), this, SLOT(doScanButton())); + connect(TabWidget2, SIGNAL(currentChanged(QWidget *)), this, SLOT(doTabChanged())); + timerid = -1; // Is this not possible normally? +} + +/* + * Destroys the object and frees any allocated resources + */ +GSMTool::~GSMTool() +{ + // no need to delete child widgets, Qt does it all for us + if (devicelocked) + unlockDevice(); +} +const speed_t GSMTool::baudrates[12] = { + B300, B600, B1200, B2400, B4800, B9600, B19200, + B38400, B57600, B115200, B230400, B460800 +}; + +int GSMTool::lockDevice( ) +{ + devicelocked = 1; + /* FIXME */ + return 0; +} + +void GSMTool::unlockDevice( ) +{ + devicelocked = 0; +} + +void GSMTool::setConnected( bool conn ) +{ + TabWidget2->setTabEnabled(tab_2, conn); + TabWidget2->setTabEnabled(tab_3, conn); + MfrLabel->setEnabled(conn); + MfrText->setEnabled(conn); + ModelLabel->setEnabled(conn); + ModelText->setEnabled(conn); + RevisionLabel->setEnabled(conn); + RevisionText->setEnabled(conn); + SerialLabel->setEnabled(conn); + SerialText->setEnabled(conn); + +} +void GSMTool::doTabChanged() +{ + int index = TabWidget2->currentPageIndex(); + qDebug("tab changed to %d", index); + + if (index == 1) { + timerid = startTimer(5000); + timerEvent(NULL); + } else if (timerid != -1) { + killTimer(timerid); + timerid = -1; + } +} + +void GSMTool::timerEvent( QTimerEvent * ) +{ + OPInfo opi; + + opi = me->getCurrentOPInfo(); + + if (opi._numericName == NOT_SET) { + NetStatText->setText("No network"); + NetworkLabel->setEnabled(FALSE); + NetworkText->setEnabled(FALSE); + NetworkText->setText(""); + SigStrText->setEnabled(FALSE); + SigStrText->setText(""); + dB->setEnabled(FALSE); + SigStrLabel->setEnabled(FALSE); + } else { + // FIXME: Add 'roaming' info from AT+CFUN + qDebug("network"); + NetStatText->setText("Registered"); + NetworkLabel->setEnabled(TRUE); + NetworkText->setEnabled(TRUE); + NetworkText->setText(opi._longName.c_str()); + SigStrText->setEnabled(TRUE); + + qDebug("get sig str"); + int csq = me->getSignalStrength(); + if (csq == 0) { + SigStrText->setText("<= -113"); + dB->setEnabled(TRUE); + SigStrLabel->setEnabled(TRUE); + } else if (csq == 99) { + SigStrText->setText("Unknown"); + dB->setEnabled(FALSE); + SigStrLabel->setEnabled(FALSE); + } else { + char buf[6]; + sprintf(buf, "%d", -113 + (2*csq)); + SigStrText->setText(buf); + dB->setEnabled(TRUE); + SigStrLabel->setEnabled(TRUE); + } + } +} + +void GSMTool::doScanButton() +{ + qDebug("ScanButton"); +} +/* + * A simple slot... not very interesting. + */ +void GSMTool::doConnectButton() +{ + speed_t rate; + devicename = strdup(DeviceName->currentText().local8Bit().data()); + rate = baudrates[BaudRate->currentItem()]; + + qDebug("Connect Button Pressed"); + MfrText->setText("Opening..."); + ModelText->setText(""); + RevisionText->setText(""); + SerialText->setText(""); + + setConnected(FALSE); + if (me) { + // delete me; + me = NULL; + } + if (port) { + // delete port; + port = NULL; + } + + if (lockDevice()) { + qDebug("lockDevice() failed\n"); + }; + + qDebug("Device name is %s\n", devicename); + + try { + port = new UnixSerialPort(devicename, rate, DEFAULT_INIT_STRING, 0); + } catch (GsmException) { + qDebug("port failed"); + return; + } + MfrText->setText("Initialising..."); + qDebug("got port"); + try { + me = new MeTa(port); + } catch (GsmException) { + qDebug("meta failed"); + delete port; + port = NULL; + unlockDevice(); + return; + } + + qDebug("Opened"); + + MEInfo ifo; + + MfrText->setText("Querying..."); + + try { + ifo = me->getMEInfo(); + } catch (GsmException) { + qDebug("getMEInfo failed"); + delete me; + me = NULL; + delete port; + port = NULL; + unlockDevice(); + return; + } + + MfrText->setText(ifo._manufacturer.c_str()); + ModelText->setText(ifo._model.c_str()); + RevisionText->setText(ifo._revision.c_str()); + SerialText->setText(ifo._serialNumber.c_str()); + setConnected(TRUE); +} diff --git a/noncore/unsupported/gsmtool/gsmtool.h b/noncore/unsupported/gsmtool/gsmtool.h new file mode 100644 index 0000000..cb19f54 --- a/dev/null +++ b/noncore/unsupported/gsmtool/gsmtool.h @@ -0,0 +1,41 @@ +#ifndef EXAMPLE_H +#define EXAMPLE_H +#include "gsmtoolbase.h" + +#include + +#include + +class GSMTool : public GSMToolBase +{ + Q_OBJECT + +public: + GSMTool( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~GSMTool(); + +protected: + void timerEvent(QTimerEvent *te ); + +private slots: + void doConnectButton(); + void doScanButton(); + void doTabChanged(); +private: + static const speed_t baudrates[]; + int devicelocked; + int timerid; + + gsmlib::MeTa *me; + gsmlib::Port *port; + + char *devicename; + speed_t baudrate; + + int lockDevice( ); + void unlockDevice( ); + + void setConnected( bool conn ); +}; + +#endif // EXAMPLE_H diff --git a/noncore/unsupported/gsmtool/gsmtool.pro b/noncore/unsupported/gsmtool/gsmtool.pro new file mode 100644 index 0000000..0f5fb43 --- a/dev/null +++ b/noncore/unsupported/gsmtool/gsmtool.pro @@ -0,0 +1,13 @@ +TEMPLATE = app +#CONFIG = qt warn_on debug +CONFIG = qt warn_on release +DESTDIR = $(OPIEDIR)/bin +HEADERS = gsmtool.h +SOURCES = main.cpp gsmtool.cpp +CXXFLAGS += -fexceptions +INCLUDEPATH += $(OPIEDIR)/include +INCLUDEPATH += $(GSMLIBDIR) +DEPENDPATH += $(OPIEDIR)/include +LIBS += -lqpe -L$(GSMLIBDIR)/gsmlib/.libs -lgsmme +INTERFACES = gsmtoolbase.ui +TARGET = gsmtool diff --git a/noncore/unsupported/gsmtool/gsmtoolbase.ui b/noncore/unsupported/gsmtool/gsmtoolbase.ui new file mode 100644 index 0000000..36a3d8e --- a/dev/null +++ b/noncore/unsupported/gsmtool/gsmtoolbase.ui @@ -0,0 +1,887 @@ + +GSMToolBase + + QWidget + + name + GSM Tool + + + geometry + + 0 + 0 + 272 + 366 + + + + caption + GSM Tool + + + layoutMargin + + + layoutSpacing + + + + margin + 2 + + + spacing + 1 + + + QTabWidget + + name + TabWidget2 + + + sizePolicy + + 7 + 7 + + + + focusPolicy + NoFocus + + + layoutMargin + + + layoutSpacing + + + QWidget + + name + tab + + + title + Device + + + + margin + 2 + + + spacing + 1 + + + QLabel + + name + DeviceLabel + + + text + Modem Device: + + + + QComboBox + + + text + /dev/ircomm0 + + + + + text + /dev/ttySA0 + + + + + text + /dev/ttyS0 + + + + name + DeviceName + + + editable + true + + + currentItem + 0 + + + + QLabel + + name + BaudLabel + + + text + Baud Rate: + + + + QLayoutWidget + + name + Layout8 + + + layoutMargin + + + + margin + 0 + + + spacing + 1 + + + QComboBox + + + text + 300 + + + + + text + 600 + + + + + text + 1200 + + + + + text + 2400 + + + + + text + 4800 + + + + + text + 9600 + + + + + text + 19200 + + + + + text + 38400 + + + + + text + 57600 + + + + + text + 115200 + + + + + text + 230400 + + + + + text + 460800 + + + + name + BaudRate + + + editable + false + + + currentItem + 6 + + + + + name + Spacer5 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QPushButton + + name + ConnectButton + + + sizePolicy + + 1 + 1 + + + + text + Connect + + + + + + Line + + name + Line1 + + + orientation + Horizontal + + + + QLabel + + name + MfrLabel + + + enabled + true + + + text + Manufacturer: + + + + QLineEdit + + name + MfrText + + + sizePolicy + + 1 + 0 + + + + focusPolicy + NoFocus + + + text + + + + + QLabel + + name + ModelLabel + + + text + Model: + + + + QLineEdit + + name + ModelText + + + focusPolicy + NoFocus + + + + QLabel + + name + RevisionLabel + + + text + Revision: + + + + QLineEdit + + name + RevisionText + + + focusPolicy + NoFocus + + + + QLabel + + name + SerialLabel + + + text + Serial Number: + + + + QLineEdit + + name + SerialText + + + focusPolicy + NoFocus + + + + + name + Spacer6 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + + + QWidget + + name + tab + + + title + Network + + + + margin + 0 + + + spacing + 1 + + + QLabel + + name + NetStatLabel + + + text + Network Status: + + + + QLineEdit + + name + NetStatText + + + focusPolicy + NoFocus + + + + QLabel + + name + NetworkLabel + + + text + Current Network: + + + + QLineEdit + + name + NetworkText + + + focusPolicy + NoFocus + + + + QLayoutWidget + + name + Layout7 + + + layoutMargin + + + + margin + 0 + + + spacing + 1 + + + QLabel + + name + SigStrLabel + + + text + Signal Strength: + + + + QLineEdit + + name + SigStrText + + + focusPolicy + NoFocus + + + + QLabel + + name + dB + + + text + dBm + + + + + + QLayoutWidget + + name + Layout9 + + + layoutMargin + + + + margin + 0 + + + spacing + 1 + + + QLabel + + name + AltNetsLabel + + + text + Alternative Networks: + + + + + name + Spacer13 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QPushButton + + name + ScanButton + + + text + Scan + + + + + + QListView + + + text + Network Name + + + clickable + true + + + resizeable + true + + + + + text + Status + + + clickable + true + + + resizeable + true + + + + + text + No. + + + clickable + true + + + resizeable + true + + + + + text + Shortname + + + clickable + true + + + resizeable + true + + + + name + NetworkList + + + sizePolicy + + 7 + 7 + + + + + QLayoutWidget + + name + Layout11 + + + + margin + 2 + + + spacing + 1 + + + + name + Spacer14 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QPushButton + + name + RegisterButton + + + sizePolicy + + 7 + 0 + + + + text + Register + + + + + + + + QWidget + + name + tab + + + title + SMS + + + + margin + 2 + + + spacing + 1 + + + QComboBox + + + text + None + + + + + text + Incoming + + + + + text + Outgoing + + + + name + ComboBox11 + + + enabled + true + + + + QLabel + + name + TextLabel4 + + + text + Message Collection: + + + + QListView + + + text + Date + + + clickable + true + + + resizeable + true + + + + + text + Number + + + clickable + true + + + resizeable + true + + + + name + ListView3 + + + + QMultiLineEdit + + name + MultiLineEdit3 + + + readOnly + true + + + + QLayoutWidget + + name + Layout15 + + + layoutMargin + + + + margin + 0 + + + spacing + 1 + + + QPushButton + + name + PushButton11 + + + text + Delete + + + + QPushButton + + name + PushButton12 + + + text + Send + + + + QPushButton + + name + PushButton13 + + + text + New + + + + + + + + + + diff --git a/noncore/unsupported/gsmtool/main.cpp b/noncore/unsupported/gsmtool/main.cpp new file mode 100644 index 0000000..8f68713 --- a/dev/null +++ b/noncore/unsupported/gsmtool/main.cpp @@ -0,0 +1,12 @@ +#include "gsmtool.h" +#include + +int main( int argc, char ** argv ) +{ + QPEApplication a( argc, argv ); + + GSMTool mw; + a.showMainWidget( &mw ); + + return a.exec(); +} diff --git a/noncore/unsupported/gsmtool/opie-gsmtool.control b/noncore/unsupported/gsmtool/opie-gsmtool.control new file mode 100644 index 0000000..5db0450 --- a/dev/null +++ b/noncore/unsupported/gsmtool/opie-gsmtool.control @@ -0,0 +1,10 @@ +Files: bin/gsmtool apps/Applications/gsmtool.desktop pics/gsmtool +Priority: optional +Section: opie/applications +Maintainer: David Woodhouse +Architecture: arm +Version: 1.0.0 +Depends: qpe-base ($QPE_VERSION) +License: Public Domain +Description: GSMTool program + An GSM phone utility program for the Opie environment. -- cgit v0.9.0.2