-rw-r--r-- | noncore/net/opietooth/lib/connection.cpp | 4 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/connection.h | 31 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/lib.pro | 4 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/startpanconnection.cpp | 67 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/startpanconnection.h | 40 |
5 files changed, 144 insertions, 2 deletions
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 @@ -1,90 +1,94 @@ #include "connection.h" using namespace OpieTooth; + + + + ConnectionState::ConnectionState() { m_direction = Incoming; m_handle = -1; m_state = -1; m_linkMode = -1; }; ConnectionState::ConnectionState( const ConnectionState& con1 ) { (*this) = con1; } ConnectionState::ConnectionState( bool in, const QString& conType, const QString& mac, int handle, int state, int linkMode ) { m_direction = in; m_contype = conType; m_mac = mac; m_handle = handle; m_state = state; m_linkMode = linkMode; } void ConnectionState::setDirection( bool incoming ) { m_direction = incoming; } bool ConnectionState::direction() const { return m_direction; } void ConnectionState::setConnectionMode( const QString& conType ) { m_contype = conType; } QString ConnectionState::connectionMode() const { return m_contype; } void ConnectionState::setMac( const QString& mac ) { m_mac = mac; } QString ConnectionState::mac() const{ return m_mac; } void ConnectionState::setHandle( int handle ) { m_handle = handle; } int ConnectionState::handle() const{ return m_handle; } void ConnectionState::setState( int state ) { m_state = state; } int ConnectionState::state()const { return m_state; } void ConnectionState::setLinkMode( int linkMode ) { m_linkMode = linkMode; } int ConnectionState::linkMode()const{ return m_linkMode; } ConnectionState &ConnectionState::operator=( const ConnectionState& con1 ) { m_direction = con1.m_direction; m_contype = con1.m_contype; m_mac = con1.m_mac; m_handle = con1.m_handle; m_state = con1.m_state; m_linkMode = con1.m_linkMode; return (*this); } 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 @@ -1,105 +1,136 @@ #ifndef OpieTooth_Connection_H #define OpieTooth_Connection_H #include <qstring.h> #include <qvaluelist.h> +#include <qobject.h> 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 }; /** * The Connection class stores * the output of hcitool con * in a OO way */ class ConnectionState { public: /** * typedef for a list of * Connections */ typedef QValueList<ConnectionState> ValueList; /** * Copy c'tor. */ ConnectionState( const ConnectionState& ); /** * Main c'tor * Basicly it holds all values * a blueZ connections can have * @param in If the connection is either incoming or outgoing * @param conType Either ACL or SCO for connection type * @param mac The BD Address( mac ) of the peer * @param handle the blueZ handle * @param state the State of the connection * @param linkMode the linkmode of the connection MASTER or not * * < ACL 00:02:C7:09:2B:53 handle 1 state 1 lm MASTER * */ ConnectionState( bool in, const QString& conType, const QString& mac, int handle, int state, int linkMode ); /** * C'tor for compability with QValueList * QValueList needs this c'tor. */ ConnectionState(); /** * Set if the connection is incoming or * outgoing * @param in Whether or not the connection is ingoing or not. * for param use either Incoming or Outgoing * */ void setDirection( bool incoming = Incoming ); /** * direction() will return Incoming( true ) * if the direction is incomoning or Outgoing( false) * if outgoing */ bool direction() const; /** * sets the ConnectionMode * @param comMode I know that SCO and ACL exists so far */ void setConnectionMode( const QString& comMode ); /** * linkMode returns the linkMode * MASTER for example */ QString connectionMode() const; /** * The Bluetooth Address or mac * is set by this function * @param mac the BluetoothAddress( mac) */ void setMac( const QString& mac); /** * returns the mac */ QString mac() const; /** * Set the handle of the bt connection */ void setHandle(int handle ); 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,30 +1,30 @@ 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) LIBS += -lopie #VERSION = 0.0.0 TRANSLATIONS = ../../../../i18n/de/libopietooth.ts \ ../../../../i18n/da/libopietooth.ts \ ../../../../i18n/xx/libopietooth.ts \ ../../../../i18n/en/libopietooth.ts \ ../../../../i18n/es/libopietooth.ts \ ../../../../i18n/fr/libopietooth.ts \ ../../../../i18n/hu/libopietooth.ts \ ../../../../i18n/ja/libopietooth.ts \ ../../../../i18n/ko/libopietooth.ts \ ../../../../i18n/no/libopietooth.ts \ ../../../../i18n/pl/libopietooth.ts \ ../../../../i18n/pt/libopietooth.ts \ ../../../../i18n/pt_BR/libopietooth.ts \ ../../../../i18n/sl/libopietooth.ts \ ../../../../i18n/zh_CN/libopietooth.ts \ ../../../../i18n/zh_TW/libopietooth.ts include ( $(OPIEDIR)/include.pro ) 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 <qobject.h> +#include "connection.h" +#include <opie/oprocess.h> + +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 |