summaryrefslogtreecommitdiff
authorzecke <zecke>2002-06-28 20:41:55 (UTC)
committer zecke <zecke>2002-06-28 20:41:55 (UTC)
commit545d7b51d67e4c1fa6be40436103b0a6b237a3a7 (patch) (side-by-side diff)
tree7a40a66ef8798e51a23ac362254788609f818f17
parent8a34a47d873d8d767d0a84a828e6724b73295b8d (diff)
downloadopie-545d7b51d67e4c1fa6be40436103b0a6b237a3a7.zip
opie-545d7b51d67e4c1fa6be40436103b0a6b237a3a7.tar.gz
opie-545d7b51d67e4c1fa6be40436103b0a6b237a3a7.tar.bz2
hcitool con additions ( not done yet )
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/lib/connection.cpp90
-rw-r--r--noncore/net/opietooth/lib/connection.h150
-rw-r--r--noncore/net/opietooth/lib/lib.pro4
-rw-r--r--noncore/net/opietooth/lib/manager.h231
4 files changed, 366 insertions, 109 deletions
diff --git a/noncore/net/opietooth/lib/connection.cpp b/noncore/net/opietooth/lib/connection.cpp
new file mode 100644
index 0000000..1f9baaf
--- a/dev/null
+++ b/noncore/net/opietooth/lib/connection.cpp
@@ -0,0 +1,90 @@
+
+#include "connection.h"
+
+using namespace OpieTooth;
+
+Connection::Connection() {
+ m_direction = Incoming;
+ m_handle = -1;
+ m_state = -1;
+ m_linkMode = -1;
+};
+
+Connection::Connection( const Connection& con1 ) {
+ (*this) = con1;
+}
+
+
+Connection::Connection( 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 Connection::setDirection( bool incoming ) {
+ m_direction = incoming;
+}
+
+bool Connection::direction() const {
+ return m_direction;
+}
+
+void Connection::setConnectionMode( const QString& conType ) {
+ m_contype = conType;
+}
+
+QString Connection::connectionMode() const {
+ return m_contype;
+}
+
+void Connection::setMac( const QString& mac ) {
+ m_mac = mac;
+}
+
+QString Connection::mac() const{
+ return m_mac;
+}
+
+void Connection::setHandle( int handle ) {
+ m_handle = handle;
+}
+
+int Connection::handle() const{
+ return m_handle;
+}
+
+void Connection::setState( int state ) {
+ m_state = state;
+}
+
+int Connection::state()const {
+ return m_state;
+}
+
+void Connection::setLinkMode( int linkMode ) {
+ m_linkMode = linkMode;
+}
+
+int Connection::linkMode()const{
+ return m_linkMode;
+}
+
+Connection &Connection::operator=( const Connection& 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
new file mode 100644
index 0000000..37090ce
--- a/dev/null
+++ b/noncore/net/opietooth/lib/connection.h
@@ -0,0 +1,150 @@
+
+#ifndef OpieTooth_Connection_H
+#define OpieTooth_Connection_H
+
+#include <qstring.h>
+#include <qvaluelist.h>
+
+namespace OpieTooth {
+
+ 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 Connection {
+ public:
+ /**
+ * typedef for a list of
+ * Connections
+ */
+ typedef QValueList<Connection> ValueList;
+
+ /**
+ * Copy c'tor.
+ */
+ Connection( const Connection& );
+
+ /**
+ * 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
+ *
+ */
+ Connection( 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.
+ */
+ Connection();
+
+ /**
+ * 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 );
+
+ /**
+ * @return the handle of the connection
+ */
+ int handle() const;
+
+ /**
+ * sets the state
+ */
+ void setState( int state );
+
+ /**
+ * return the state
+ */
+ int state() const;
+
+ /**
+ * Sets the link mode of the Connection
+ */
+ void setLinkMode( int linkMode = Master );
+
+ /**
+ * returns the linkMode
+ */
+ int linkMode()const;
+
+ /**
+ * copy c'tor
+ */
+ Connection &operator=( const Connection& );
+
+ private:
+ class ConnectionPrivate;
+ ConnectionPrivate *d;
+ bool m_direction : 1;
+ QString m_contype;
+ QString m_mac;
+ int m_handle;
+ int m_state;
+ int m_linkMode;
+
+ };
+};
+
+
+#endif
diff --git a/noncore/net/opietooth/lib/lib.pro b/noncore/net/opietooth/lib/lib.pro
index ecf2e6c..dde6c2a 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 = parser.h device.h manager.h remotedevice.h services.h
-SOURCES = parser.cc device.cc manager.cc remotedevice.cc services.cc
+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
TARGET = opietooth
INCLUDEPATH += $(OPIEDIR)/include .
DESTDIR = $(QTDIR)/lib$(PROJMAK)
diff --git a/noncore/net/opietooth/lib/manager.h b/noncore/net/opietooth/lib/manager.h
index 415ec72..2589e9b 100644
--- a/noncore/net/opietooth/lib/manager.h
+++ b/noncore/net/opietooth/lib/manager.h
@@ -12,120 +12,137 @@
class OProcess;
namespace OpieTooth {
- class Device;
- /** Manager manages a blueZ device (hci0 for example)
- * with Manager you can control the things you
- * could do from command line in a OO and asynchronus
- * way.
- */
- class Manager : public QObject {
-Q_OBJECT
- public:
- /** c'tor whichs create a new Manager
- * @param device is the device to use. Either a mac or blueZ device name
- *
+ class Device;
+ /** Manager manages a blueZ device (hci0 for example)
+ * without Manager you can control the things you
+ * could do from command line in a OO and asynchronus
+ * way.
*/
- Manager( const QString &device );
- /** c'tor
- * @param dev The Device to be managed
- * We don't care of Device so you need to delete it
- */
- Manager( Device* dev );
- /**
- * c'tor
- */
- Manager();
- ~Manager();
+ class Manager : public QObject {
+ Q_OBJECT
+ public:
+ /** c'tor whichs create a new Manager
+ * @param device is the device to use. Either a mac or blueZ device name
+ *
+ */
+ Manager( const QString &device );
- /** Set the manager to control a new device
- * @param device the new device to control (hci0 )
- */
- void setDevice( const QString& device );
- /**
- * Convience functions for setting a new device
- */
- void setDevice( Device *dev );
- /**
- * Wether or not a device is connected. The function
- * is asynchron
- * If device is empty it will take the currently managed
- * device and see if it's up
- * for Remote devices it will ping and see.
- * @param either mac or hciX
- */
- void isAvailable(const QString& device= QString::null );
- /**
- * same as above
- */
- void isAvailable(Device *dev );
+ /** c'tor
+ * @param dev The Device to be managed
+ * We don't care of Device so you need to delete it
+ */
+ Manager( Device* dev );
- /** this searchs for devices reachable from the
- * currently managed device
- * or from device if @param device is not empty
- */
- void searchDevices(const QString& device= QString::null );
- /** same as above
- *
- */
- void searchDevices(Device *d );
+ /**
+ * c'tor
+ */
+ Manager();
- /**
- * This will add the service @param name
- * to the sdpd daemon
- * It will start the daemon if necessary
- */
- void addService(const QString &name );
- /**
- * This will add the services @param names
- * to the sdpd daemon
- * It will start the daemon if necessary
- */
- void addServices( const QStringList& names );
- /**
- * This removes a service from the sdps
- */
- void removeService(const QString &name );
- /**
- * Removes a list from the sdpd
- */
- void removeServices(const QStringList& );
+ ~Manager();
- /**
- * search for services on a remote device
- *
- */
- void searchServices( const QString& remDevice );
- /**
- * search for services on a remote device
- */
- void searchServices( const RemoteDevice& );
- /*static*/ QString toDevice( const QString& mac );
- /*static*/ QString toMac( const QString &device );
-
- signals:
- // device either mac or dev name
- // the first device is the device which you access
- void available( const QString& device, bool connected );
- void addedService( const QString& service, bool added );
- void removedService( const QString& service, bool removed );
- void foundServices( const QString& device, Services::ValueList );
- void foundDevices( const QString& device, RemoteDevice::ValueList );
+ /** Set the manager to control a new device
+ * @param device the new device to control (hci0 )
+ */
+ void setDevice( const QString& device );
+
+ /**
+ * Convience functions for setting a new device
+ */
+ void setDevice( Device *dev );
+
+ /**
+ * Wether or not a device is connected. The function
+ * is asynchron
+ * If device is empty it will take the currently managed
+ * device and see if it's up
+ * for Remote devices it will ping and see.
+ * @param either mac or hciX
+ */
+ void isAvailable(const QString& device= QString::null );
+
+ /**
+ * same as above
+ */
+ void isAvailable(Device *dev );
+
+ /** this searchs for devices reachable from the
+ * currently managed device
+ * or from device if @param device is not empty
+ */
+ void searchDevices(const QString& device= QString::null );
+ /** same as above
+ *
+ */
+ void searchDevices(Device *d );
+
+ /**
+ * This will add the service @param name
+ * to the sdpd daemon
+ * It will start the daemon if necessary
+ */
+ void addService(const QString &name );
+
+ /**
+ * This will add the services @param names
+ * to the sdpd daemon
+ * It will start the daemon if necessary
+ */
+ void addServices( const QStringList& names );
+
+ /**
+ * This removes a service from the sdps
+ */
+ void removeService(const QString &name );
+
+ /**
+ * Removes a list from the sdpd
+ */
+ void removeServices(const QStringList& );
+
+ /**
+ * search for services on a remote device
+ *
+ */
+ void searchServices( const QString& remDevice );
+
+ /**
+ * search for services on a remote device
+ */
+ void searchServices( const RemoteDevice& );
+ /*static*/ QString toDevice( const QString& mac );
+ /*static*/ QString toMac( const QString &device );
+
+ signals:
+ // device either mac or dev name
+ // the first device is the device which you access
+ void available( const QString& device, bool connected );
+ void addedService( const QString& service, bool added );
+ void removedService( const QString& service, bool removed );
+ void foundServices( const QString& device, Services::ValueList );
+ void foundDevices( const QString& device, RemoteDevice::ValueList );
+ void connections( Connection::ValueList );
private slots:
- void slotProcessExited(OProcess* );
- void slotSDPExited(OProcess*);
- void slotSDPOut(OProcess*, char*, int);
- void slotHCIExited(OProcess* );
- void slotHCIOut(OProcess*, char*, int );
- private:
- Services::ValueList parseSDPOutput( const QString& );
- RemoteDevice::ValueList parseHCIOutput( const QString& );
- OProcess *m_hcitool;
- OProcess *m_sdp; // not only one
- QString m_device;
- QMap<QString, QString> m_out;
- QMap<QString, QString> m_devices;
- };
+ void slotProcessExited(OProcess* );
+
+ void slotSDPExited(OProcess*);
+ void slotSDPOut(OProcess*, char*, int);
+
+ void slotHCIExited(OProcess* );
+ void slotHCIOut(OProcess*, char*, int );
+
+ void slotConnectionExited(OProcess* );
+ void slotConnectionOutput(OProcess*, char*, int );
+ private:
+ Services::ValueList parseSDPOutput( const QString& );
+ RemoteDevice::ValueList parseHCIOutput( const QString& );
+ OProcess *m_hcitool;
+ OProcess *m_sdp; // not only one
+ QString m_device;
+ QMap<QString, QString> m_out;
+ QMap<QString, QString> m_devices;
+ QString m_hcitoolCon;
+ };
};
#endif