summaryrefslogtreecommitdiff
authorzecke <zecke>2002-06-28 20:41:55 (UTC)
committer zecke <zecke>2002-06-28 20:41:55 (UTC)
commit545d7b51d67e4c1fa6be40436103b0a6b237a3a7 (patch) (unidiff)
tree7a40a66ef8798e51a23ac362254788609f818f17
parent8a34a47d873d8d767d0a84a828e6724b73295b8d (diff)
downloadopie-545d7b51d67e4c1fa6be40436103b0a6b237a3a7.zip
opie-545d7b51d67e4c1fa6be40436103b0a6b237a3a7.tar.gz
opie-545d7b51d67e4c1fa6be40436103b0a6b237a3a7.tar.bz2
hcitool con additions ( not done yet )
Diffstat (more/less context) (show 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.h19
4 files changed, 260 insertions, 3 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 @@
1
2#include "connection.h"
3
4using namespace OpieTooth;
5
6Connection::Connection() {
7 m_direction = Incoming;
8 m_handle = -1;
9 m_state = -1;
10 m_linkMode = -1;
11};
12
13Connection::Connection( const Connection& con1 ) {
14 (*this) = con1;
15}
16
17
18Connection::Connection( bool in,
19 const QString& conType,
20 const QString& mac,
21 int handle,
22 int state,
23 int linkMode ) {
24 m_direction = in;
25 m_contype = conType;
26 m_mac = mac;
27 m_handle = handle;
28 m_state = state;
29 m_linkMode = linkMode;
30
31}
32
33void Connection::setDirection( bool incoming ) {
34 m_direction = incoming;
35}
36
37bool Connection::direction() const {
38 return m_direction;
39}
40
41void Connection::setConnectionMode( const QString& conType ) {
42 m_contype = conType;
43}
44
45QString Connection::connectionMode() const {
46 return m_contype;
47}
48
49void Connection::setMac( const QString& mac ) {
50 m_mac = mac;
51}
52
53QString Connection::mac() const{
54 return m_mac;
55}
56
57void Connection::setHandle( int handle ) {
58 m_handle = handle;
59}
60
61int Connection::handle() const{
62 return m_handle;
63}
64
65void Connection::setState( int state ) {
66 m_state = state;
67}
68
69int Connection::state()const {
70 return m_state;
71}
72
73void Connection::setLinkMode( int linkMode ) {
74 m_linkMode = linkMode;
75}
76
77int Connection::linkMode()const{
78 return m_linkMode;
79}
80
81Connection &Connection::operator=( const Connection& con1 ) {
82 m_direction = con1.m_direction;
83 m_contype = con1.m_contype;
84 m_mac = con1.m_mac;
85 m_handle = con1.m_handle;
86 m_state = con1.m_state;
87 m_linkMode = con1.m_linkMode;
88
89 return (*this);
90}
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 @@
1
2#ifndef OpieTooth_Connection_H
3#define OpieTooth_Connection_H
4
5#include <qstring.h>
6#include <qvaluelist.h>
7
8namespace OpieTooth {
9
10 enum LinkDirection { Incoming= true, Outgoing = false };
11 enum LinkMode { Master =0, Client };
12
13
14 /**
15 * The Connection class stores
16 * the output of hcitool con
17 * in a OO way
18 */
19
20 class Connection {
21 public:
22 /**
23 * typedef for a list of
24 * Connections
25 */
26 typedef QValueList<Connection> ValueList;
27
28 /**
29 * Copy c'tor.
30 */
31 Connection( const Connection& );
32
33 /**
34 * Main c'tor
35 * Basicly it holds all values
36 * a blueZ connections can have
37 * @param in If the connection is either incoming or outgoing
38 * @param conType Either ACL or SCO for connection type
39 * @param mac The BD Address( mac ) of the peer
40 * @param handle the blueZ handle
41 * @param state the State of the connection
42 * @param linkMode the linkmode of the connection MASTER or not
43 *
44 * < ACL 00:02:C7:09:2B:53 handle 1 state 1 lm MASTER
45 *
46 */
47 Connection( bool in,
48 const QString& conType,
49 const QString& mac,
50 int handle,
51 int state,
52 int linkMode );
53
54 /**
55 * C'tor for compability with QValueList
56 * QValueList needs this c'tor.
57 */
58 Connection();
59
60 /**
61 * Set if the connection is incoming or
62 * outgoing
63 * @param in Whether or not the connection is ingoing or not.
64 * for param use either Incoming or Outgoing
65 *
66 */
67 void setDirection( bool incoming = Incoming );
68
69 /**
70 * direction() will return Incoming( true )
71 * if the direction is incomoning or Outgoing( false)
72 * if outgoing
73 */
74 bool direction() const;
75
76 /**
77 * sets the ConnectionMode
78 * @param comMode I know that SCO and ACL exists so far
79 */
80 void setConnectionMode( const QString& comMode );
81
82 /**
83 * linkMode returns the linkMode
84 * MASTER for example
85 */
86 QString connectionMode() const;
87
88 /**
89 * The Bluetooth Address or mac
90 * is set by this function
91 * @param mac the BluetoothAddress( mac)
92 */
93 void setMac( const QString& mac);
94
95 /**
96 * returns the mac
97 */
98 QString mac() const;
99
100
101 /**
102 * Set the handle of the bt connection
103 */
104 void setHandle(int handle );
105
106 /**
107 * @return the handle of the connection
108 */
109 int handle() const;
110
111 /**
112 * sets the state
113 */
114 void setState( int state );
115
116 /**
117 * return the state
118 */
119 int state() const;
120
121 /**
122 * Sets the link mode of the Connection
123 */
124 void setLinkMode( int linkMode = Master );
125
126 /**
127 * returns the linkMode
128 */
129 int linkMode()const;
130
131 /**
132 * copy c'tor
133 */
134 Connection &operator=( const Connection& );
135
136 private:
137 class ConnectionPrivate;
138 ConnectionPrivate *d;
139 bool m_direction : 1;
140 QString m_contype;
141 QString m_mac;
142 int m_handle;
143 int m_state;
144 int m_linkMode;
145
146 };
147};
148
149
150#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 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qte warn_on release 2CONFIG += qte warn_on release
3 HEADERS = parser.h device.h manager.h remotedevice.h services.h 3 HEADERS = connection.h parser.h device.h manager.h remotedevice.h services.h
4 SOURCES = parser.cc device.cc manager.cc remotedevice.cc services.cc 4 SOURCES = connection.cpp parser.cc device.cc manager.cc remotedevice.cc services.cc
5 TARGET = opietooth 5 TARGET = opietooth
6INCLUDEPATH += $(OPIEDIR)/include . 6INCLUDEPATH += $(OPIEDIR)/include .
7DESTDIR = $(QTDIR)/lib$(PROJMAK) 7DESTDIR = $(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
@@ -14,7 +14,7 @@ class OProcess;
14namespace OpieTooth { 14namespace OpieTooth {
15 class Device; 15 class Device;
16 /** Manager manages a blueZ device (hci0 for example) 16 /** Manager manages a blueZ device (hci0 for example)
17 * with Manager you can control the things you 17 * without Manager you can control the things you
18 * could do from command line in a OO and asynchronus 18 * could do from command line in a OO and asynchronus
19 * way. 19 * way.
20 */ 20 */
@@ -26,25 +26,30 @@ Q_OBJECT
26 * 26 *
27 */ 27 */
28 Manager( const QString &device ); 28 Manager( const QString &device );
29
29 /** c'tor 30 /** c'tor
30 * @param dev The Device to be managed 31 * @param dev The Device to be managed
31 * We don't care of Device so you need to delete it 32 * We don't care of Device so you need to delete it
32 */ 33 */
33 Manager( Device* dev ); 34 Manager( Device* dev );
35
34 /** 36 /**
35 * c'tor 37 * c'tor
36 */ 38 */
37 Manager(); 39 Manager();
40
38 ~Manager(); 41 ~Manager();
39 42
40 /** Set the manager to control a new device 43 /** Set the manager to control a new device
41 * @param device the new device to control (hci0 ) 44 * @param device the new device to control (hci0 )
42 */ 45 */
43 void setDevice( const QString& device ); 46 void setDevice( const QString& device );
47
44 /** 48 /**
45 * Convience functions for setting a new device 49 * Convience functions for setting a new device
46 */ 50 */
47 void setDevice( Device *dev ); 51 void setDevice( Device *dev );
52
48 /** 53 /**
49 * Wether or not a device is connected. The function 54 * Wether or not a device is connected. The function
50 * is asynchron 55 * is asynchron
@@ -54,6 +59,7 @@ Q_OBJECT
54 * @param either mac or hciX 59 * @param either mac or hciX
55 */ 60 */
56 void isAvailable(const QString& device= QString::null ); 61 void isAvailable(const QString& device= QString::null );
62
57 /** 63 /**
58 * same as above 64 * same as above
59 */ 65 */
@@ -75,16 +81,19 @@ Q_OBJECT
75 * It will start the daemon if necessary 81 * It will start the daemon if necessary
76 */ 82 */
77 void addService(const QString &name ); 83 void addService(const QString &name );
84
78 /** 85 /**
79 * This will add the services @param names 86 * This will add the services @param names
80 * to the sdpd daemon 87 * to the sdpd daemon
81 * It will start the daemon if necessary 88 * It will start the daemon if necessary
82 */ 89 */
83 void addServices( const QStringList& names ); 90 void addServices( const QStringList& names );
91
84 /** 92 /**
85 * This removes a service from the sdps 93 * This removes a service from the sdps
86 */ 94 */
87 void removeService(const QString &name ); 95 void removeService(const QString &name );
96
88 /** 97 /**
89 * Removes a list from the sdpd 98 * Removes a list from the sdpd
90 */ 99 */
@@ -95,6 +104,7 @@ Q_OBJECT
95 * 104 *
96 */ 105 */
97 void searchServices( const QString& remDevice ); 106 void searchServices( const QString& remDevice );
107
98 /** 108 /**
99 * search for services on a remote device 109 * search for services on a remote device
100 */ 110 */
@@ -110,13 +120,19 @@ Q_OBJECT
110 void removedService( const QString& service, bool removed ); 120 void removedService( const QString& service, bool removed );
111 void foundServices( const QString& device, Services::ValueList ); 121 void foundServices( const QString& device, Services::ValueList );
112 void foundDevices( const QString& device, RemoteDevice::ValueList ); 122 void foundDevices( const QString& device, RemoteDevice::ValueList );
123 void connections( Connection::ValueList );
113 124
114private slots: 125private slots:
115 void slotProcessExited(OProcess* ); 126 void slotProcessExited(OProcess* );
127
116 void slotSDPExited(OProcess*); 128 void slotSDPExited(OProcess*);
117 void slotSDPOut(OProcess*, char*, int); 129 void slotSDPOut(OProcess*, char*, int);
130
118 void slotHCIExited(OProcess* ); 131 void slotHCIExited(OProcess* );
119 void slotHCIOut(OProcess*, char*, int ); 132 void slotHCIOut(OProcess*, char*, int );
133
134 void slotConnectionExited(OProcess* );
135 void slotConnectionOutput(OProcess*, char*, int );
120 private: 136 private:
121 Services::ValueList parseSDPOutput( const QString& ); 137 Services::ValueList parseSDPOutput( const QString& );
122 RemoteDevice::ValueList parseHCIOutput( const QString& ); 138 RemoteDevice::ValueList parseHCIOutput( const QString& );
@@ -125,6 +141,7 @@ private slots:
125 QString m_device; 141 QString m_device;
126 QMap<QString, QString> m_out; 142 QMap<QString, QString> m_out;
127 QMap<QString, QString> m_devices; 143 QMap<QString, QString> m_devices;
144 QString m_hcitoolCon;
128 }; 145 };
129}; 146};
130 147