From d3f71dadbd2dafcf42480afeffe75e7e36ec7d9c Mon Sep 17 00:00:00 2001 From: harlekin Date: Fri, 21 Mar 2003 15:56:58 +0000 Subject: move connection work to the lib --- (limited to 'noncore/net/opietooth') diff --git a/noncore/net/opietooth/lib/connection.cpp b/noncore/net/opietooth/lib/connection.cpp index ef7d925..5e35463 100644 --- a/noncore/net/opietooth/lib/connection.cpp +++ b/noncore/net/opietooth/lib/connection.cpp @@ -3,6 +3,10 @@ using namespace OpieTooth; + + + + ConnectionState::ConnectionState() { m_direction = Incoming; m_handle = -1; diff --git a/noncore/net/opietooth/lib/connection.h b/noncore/net/opietooth/lib/connection.h index 76e5dad..a0c50f2 100644 --- a/noncore/net/opietooth/lib/connection.h +++ b/noncore/net/opietooth/lib/connection.h @@ -4,9 +4,40 @@ #include #include +#include namespace OpieTooth { + + + + /** + * Parent class for all kinds of starting connection + * subclasses + * + */ + class StartConnection : public QObject { + + protected: + + enum ConnectionType{ + Pan = 0, + Rfcomm, + Obex, + Hci + }; + + virtual ~StartConnection() {}; + + virtual QString name() = 0; + virtual void setName( QString name ) = 0; + virtual ConnectionType type() = 0; + virtual void setConnectionType() = 0; + virtual void start() = 0; + virtual void stop() = 0; + + }; + enum LinkDirection { Incoming= true, Outgoing = false }; enum LinkMode { Master =0, Client }; diff --git a/noncore/net/opietooth/lib/lib.pro b/noncore/net/opietooth/lib/lib.pro index 88df1fb..d081b5c 100644 --- a/noncore/net/opietooth/lib/lib.pro +++ b/noncore/net/opietooth/lib/lib.pro @@ -1,7 +1,7 @@ TEMPLATE = lib CONFIG += qte warn_on release -HEADERS = connection.h parser.h device.h manager.h remotedevice.h services.h -SOURCES = connection.cpp parser.cc device.cc manager.cc remotedevice.cc services.cc +HEADERS = connection.h parser.h device.h manager.h remotedevice.h services.h startpanconnection.h +SOURCES = connection.cpp parser.cc device.cc manager.cc remotedevice.cc services.cc startpanconnection.cpp TARGET = opietooth INCLUDEPATH += $(OPIEDIR)/include . DESTDIR = $(OPIEDIR)/lib$(PROJMAK) diff --git a/noncore/net/opietooth/lib/startpanconnection.cpp b/noncore/net/opietooth/lib/startpanconnection.cpp new file mode 100644 index 0000000..b68f02d --- a/dev/null +++ b/noncore/net/opietooth/lib/startpanconnection.cpp @@ -0,0 +1,67 @@ + +#include "startpanconnection.h" + +using namespace OpieTooth; + + +StartPanConnection::StartPanConnection() { + m_panConnect = 0l; + setConnectionType(); +} + +StartPanConnection::~StartPanConnection() { + delete m_panConnect; +} + +StartPanConnection::StartPanConnection( QString mac ) { + m_panConnect = 0l; + m_mac = mac; + setConnectionType(); +} + +void StartPanConnection::setName( QString name ) { + m_name = name; +} + +QString StartPanConnection::name() { + return m_name; +} + +void StartPanConnection::setConnectionType() { + m_connectionType = Pan; +} + +StartConnection::ConnectionType StartPanConnection::type() { + return m_connectionType; +} + +void StartPanConnection::start() { + m_panConnect = new OProcess(); + *m_panConnect << "pand" << "--connect" << m_mac; + + connect( m_panConnect, SIGNAL( processExited( OProcess* ) ) , + this, SLOT( slotExited( OProcess* ) ) ); + connect( m_panConnect, SIGNAL( receivedStdout( OProcess*, char*, int ) ), + this, SLOT( slotStdOut( OProcess*, char*, int ) ) ); + if (!m_panConnect->start( OProcess::NotifyOnExit, OProcess::AllOutput) ) { + qWarning( "could not start" ); + delete m_panConnect; + } +} + + +void StartPanConnection::slotExited( OProcess* proc ) { + delete m_panConnect; +} + +void StartPanConnection::slotStdOut(OProcess* proc, char* chars, int len) +{} + + +void StartPanConnection::stop() { + if ( m_panConnect ) { + delete m_panConnect; + m_panConnect = 0l; + } +} + diff --git a/noncore/net/opietooth/lib/startpanconnection.h b/noncore/net/opietooth/lib/startpanconnection.h new file mode 100644 index 0000000..7e5bd95 --- a/dev/null +++ b/noncore/net/opietooth/lib/startpanconnection.h @@ -0,0 +1,40 @@ +#ifndef startpanconnection_h +#define startpanconnection_h + +#include +#include "connection.h" +#include + +namespace OpieTooth { + + class StartPanConnection : StartConnection { + + Q_OBJECT + + public: + StartPanConnection(); + StartPanConnection( QString mac ); + ~StartPanConnection(); + + QString name(); + void setName( QString name ); + StartConnection::ConnectionType type(); + void setConnectionType( ); + void start(); + void stop(); + + private: + QString m_name; + QString m_mac; + ConnectionType m_connectionType; + OProcess* m_panConnect; + + private slots: + void slotExited( OProcess* proc ); + void slotStdOut( OProcess* proc, char* chars, int len ); + }; + + +} + +#endif diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index b5a09e5..04fa117 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp @@ -333,7 +333,7 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin QPopupMenu *popup =0l; if ( it != list.end() ) { qWarning("Searching id %d %s", it.key(), it.data().latin1() ); - popup = m_popHelper.find( it.key() /*1*/, + popup = m_popHelper.find( 4358, service->services(), (BTDeviceItem*)service->parent() ); }else { diff --git a/noncore/net/opietooth/manager/bluetoothbase.ui b/noncore/net/opietooth/manager/bluetoothbase.ui index b51c8c6..9ff970f 100644 --- a/noncore/net/opietooth/manager/bluetoothbase.ui +++ b/noncore/net/opietooth/manager/bluetoothbase.ui @@ -11,7 +11,7 @@ 0 0 - 228 + 224 320 @@ -19,422 +19,377 @@ caption Form1 - - QTabWidget + + layoutMargin + + + layoutSpacing + + - name - Status + margin + 0 - geometry - - 0 - 0 - 260 - 350 - + spacing + 0 - QWidget + QTabWidget name - tab + Status - - title - Devices - - - - name - Spacer3 - - - orientation - Vertical - + + layoutMargin + + + layoutSpacing + + + QWidget - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - - - name - Spacer1 + tab - - orientation - Vertical - - - sizeType - Fixed - - - sizeHint - - 20 - 20 - - - - - QListView - - - text - Device Name - - - clickable - true - - - resizeable - true - - - - - text - Online - - - clickable - true + + title + Devices + + + + margin + 2 - - resizeable - true + + spacing + 2 - - - name - ListView2 - - - geometry - - 0 - 0 - 230 - 230 - - + + QListView + + + text + Device Name + + + clickable + true + + + resizeable + true + + + + + text + Online + + + clickable + true + + + resizeable + true + + + + name + ListView2 + + + + QPushButton + + name + PushButton2 + + + sizePolicy + + 0 + 0 + + + + text + Scan for Devices + + + - QPushButton + QWidget name - PushButton2 - - - geometry - - 40 - 231 - 154 - 30 - - - - sizePolicy - - 0 - 0 - - - - text - Scan for Devices + tab - - - - QWidget - - name - tab - - - title - Connections - - - QListView - - - text - Device Name - - - clickable - true - - - resizeable - true - - - - - text - Connection type - - - clickable - true - - - resizeable - true - - - - - text - Signal - - - clickable - true + + title + Connections + + + + margin + 2 - - resizeable - true + + spacing + 2 - - - name - ListView4 - - - geometry - - 0 - 0 - 240 - 240 - - - - - - QWidget - - name - tab - - - title - Config - - - QLabel - - name - deviceNameLabel - - - geometry - - 10 - 10 - 70 - 20 - - - - text - Device Name - - - - QLabel - - name - passkeyLabel - - - geometry - - 10 - 50 - 80 - 20 - - - - text - Default Passkey - - - - QLineEdit - - name - passkeyLine - - - geometry - - 98 - 53 - 120 - 22 - - - - echoMode - Password - + + QListView + + + text + Device Name + + + clickable + true + + + resizeable + true + + + + + text + Connection type + + + clickable + true + + + resizeable + true + + + + + text + Signal + + + clickable + true + + + resizeable + true + + + + name + ListView4 + + + - QLayoutWidget + QWidget name - Layout5 - - - geometry - - 10 - 100 - 188 - 120 - + tab + + title + Config + margin - 0 + 2 spacing - 6 + 2 - QCheckBox + QLayoutWidget name - authCheckBox - - - text - enable authentification + Layout2 + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + deviceNameLabel + + + text + Device Name + + + + QLineEdit + + name + deviceNameLine + + + - QCheckBox + QLayoutWidget name - cryptCheckBox - - - text - enable encryption + Layout3 + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + passkeyLabel + + + text + Default Passkey + + + + QLineEdit + + name + passkeyLine + + + echoMode + Password + + + - QCheckBox + QLayoutWidget name - pagescanCheckBox - - - text - Enable Page scan + Layout5 + + + margin + 0 + + + spacing + 6 + + + QCheckBox + + name + authCheckBox + + + text + enable authentification + + + + QCheckBox + + name + cryptCheckBox + + + text + enable encryption + + + + QCheckBox + + name + pagescanCheckBox + + + text + Enable Page scan + + + + QCheckBox + + name + inquiryscanCheckBox + + + text + Enable Inquiry scan + + + - QCheckBox + QPushButton name - inquiryscanCheckBox + configApplyButton text - Enable Inquiry scan + Apply - QLineEdit + QWidget name - deviceNameLine - - - geometry - - 98 - 13 - 120 - 22 - - - - - QPushButton - - name - configApplyButton - - - geometry - - 60 - 230 - 99 - 32 - - - - text - Apply - - - - - QWidget - - name - tab - - - title - Status - - - QLabel - - name - StatusLabel - - - geometry - - 10 - 10 - 220 - 250 - - - - text - Status Label + tab + + title + Status + + + + margin + 2 + + + spacing + 2 + + + QLabel + + name + StatusLabel + + + text + Status Label + + + - + diff --git a/noncore/net/opietooth/manager/panpopup.cpp b/noncore/net/opietooth/manager/panpopup.cpp index d3d1347..61e632b 100644 --- a/noncore/net/opietooth/manager/panpopup.cpp +++ b/noncore/net/opietooth/manager/panpopup.cpp @@ -14,51 +14,43 @@ PanPopup::PanPopup( OpieTooth::BTDeviceItem* item ) : QPopupMenu() { qWarning("PanPopup c'tor"); m_item = item; - m_panconnect = 0l; - QAction *a, *b; + QAction *a, *b, *c; + m_panconnection = 0l; /* connect action */ - a = new QAction( ); // so it's get deleted - a->setText( "connect" ); + + + a = new QAction(); // so it's get deleted + a->setText( tr("connect") ); a->addTo( this ); connect( a, SIGNAL( activated() ), this, SLOT( slotConnect() ) ); + b = new QAction(); - b->setText( "connect+conf" ); + b->setText( tr( "connect+conf" ) ); b->addTo( this ); connect( b, SIGNAL( activated() ), this, SLOT( slotConnectAndConfig() ) ); + + c = new QAction(); + c->setText( tr( "disconnect" ) ); + c->addTo( this ); + connect( c, SIGNAL( activated() ), this, SLOT( slotDisconnect() ) ); + }; PanPopup::~PanPopup() { - delete m_panconnect; + } void PanPopup::slotConnect() { - - - // SHOULD move to lib - // before pand must be in "pand --listen --role panu" mode ( client ) - - m_panconnect = new OProcess(); - *m_panconnect << "pand" << "--connect" << m_item->mac(); - - connect( m_panconnect, SIGNAL( processExited( OProcess* ) ) , - this, SLOT( slotConnectExited( OProcess* ) ) ); - connect( m_panconnect, SIGNAL( receivedStdout( OProcess*, char*, int ) ), - this, SLOT( slotConnectOut( OProcess*, char*, int ) ) ); - if (!m_panconnect->start( OProcess::NotifyOnExit, OProcess::AllOutput) ) { - qWarning( "could not start" ); - delete m_panconnect; - } + m_panconnection = new StartPanConnection( m_item->mac() ); + m_panconnection->start(); } -void PanPopup::slotExited( OProcess* proc ) { - delete m_panconnect; +void PanPopup::slotDisconnect() { + m_panconnection->stop(); } -void PanPopup::slotStdOut(OProcess* proc, char* chars, int len) -{} - void PanPopup::slotConnectAndConfig() { slotConnect(); diff --git a/noncore/net/opietooth/manager/panpopup.h b/noncore/net/opietooth/manager/panpopup.h index 9d99f5e..1496f3a 100644 --- a/noncore/net/opietooth/manager/panpopup.h +++ b/noncore/net/opietooth/manager/panpopup.h @@ -3,10 +3,12 @@ #include #include -#include + +#include #include "btdeviceitem.h" + namespace OpieTooth { class PanPopup : public QPopupMenu { @@ -19,14 +21,13 @@ namespace OpieTooth { private: QAction* m_push; - OProcess* m_panconnect; + OpieTooth::StartPanConnection* m_panconnection; OpieTooth::BTDeviceItem *m_item; private slots: void slotConnect(); + void slotDisconnect(); void slotConnectAndConfig(); - void slotExited( OProcess* proc ); - void slotStdOut( OProcess* proc, char* chars, int len ); - }; + }; }; #endif -- cgit v0.9.0.2