author | zecke <zecke> | 2002-07-12 17:14:58 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-07-12 17:14:58 (UTC) |
commit | 89dce758480cc90502ad14b6c4cf80774e6c1845 (patch) (unidiff) | |
tree | 2ff4e635c8aa86385dfd896084f5cd419efd0840 | |
parent | 716211b5e06bb25145cfbcf62a11a7c52c79dde5 (diff) | |
download | opie-89dce758480cc90502ad14b6c4cf80774e6c1845.zip opie-89dce758480cc90502ad14b6c4cf80774e6c1845.tar.gz opie-89dce758480cc90502ad14b6c4cf80774e6c1845.tar.bz2 |
- Connection -> ConnectionState
- Factory adjustments
- Factory function
- Refactoring the QListViewItem derived class
BTListItem
|
- BTDeviceItem for RemoteDevices
|
- BTServiceItem for Services
|
- BTConnectionItem for ConnectionState
- misc bug fixes
-rw-r--r-- | noncore/net/opietooth/lib/connection.cpp | 32 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/connection.h | 16 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/manager.cc | 10 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/manager.h | 4 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 84 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.h | 11 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/btlistitem.cpp | 60 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/btlistitem.h | 21 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/manager.pro | 4 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/popuphelper.cpp | 9 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/popuphelper.h | 6 |
11 files changed, 109 insertions, 148 deletions
diff --git a/noncore/net/opietooth/lib/connection.cpp b/noncore/net/opietooth/lib/connection.cpp index 1f9baaf..ef7d925 100644 --- a/noncore/net/opietooth/lib/connection.cpp +++ b/noncore/net/opietooth/lib/connection.cpp | |||
@@ -1,90 +1,90 @@ | |||
1 | 1 | ||
2 | #include "connection.h" | 2 | #include "connection.h" |
3 | 3 | ||
4 | using namespace OpieTooth; | 4 | using namespace OpieTooth; |
5 | 5 | ||
6 | Connection::Connection() { | 6 | ConnectionState::ConnectionState() { |
7 | m_direction = Incoming; | 7 | m_direction = Incoming; |
8 | m_handle = -1; | 8 | m_handle = -1; |
9 | m_state = -1; | 9 | m_state = -1; |
10 | m_linkMode = -1; | 10 | m_linkMode = -1; |
11 | }; | 11 | }; |
12 | 12 | ||
13 | Connection::Connection( const Connection& con1 ) { | 13 | ConnectionState::ConnectionState( const ConnectionState& con1 ) { |
14 | (*this) = con1; | 14 | (*this) = con1; |
15 | } | 15 | } |
16 | 16 | ||
17 | 17 | ||
18 | Connection::Connection( bool in, | 18 | ConnectionState::ConnectionState( bool in, |
19 | const QString& conType, | 19 | const QString& conType, |
20 | const QString& mac, | 20 | const QString& mac, |
21 | int handle, | 21 | int handle, |
22 | int state, | 22 | int state, |
23 | int linkMode ) { | 23 | int linkMode ) { |
24 | m_direction = in; | 24 | m_direction = in; |
25 | m_contype = conType; | 25 | m_contype = conType; |
26 | m_mac = mac; | 26 | m_mac = mac; |
27 | m_handle = handle; | 27 | m_handle = handle; |
28 | m_state = state; | 28 | m_state = state; |
29 | m_linkMode = linkMode; | 29 | m_linkMode = linkMode; |
30 | 30 | ||
31 | } | 31 | } |
32 | 32 | ||
33 | void Connection::setDirection( bool incoming ) { | 33 | void ConnectionState::setDirection( bool incoming ) { |
34 | m_direction = incoming; | 34 | m_direction = incoming; |
35 | } | 35 | } |
36 | 36 | ||
37 | bool Connection::direction() const { | 37 | bool ConnectionState::direction() const { |
38 | return m_direction; | 38 | return m_direction; |
39 | } | 39 | } |
40 | 40 | ||
41 | void Connection::setConnectionMode( const QString& conType ) { | 41 | void ConnectionState::setConnectionMode( const QString& conType ) { |
42 | m_contype = conType; | 42 | m_contype = conType; |
43 | } | 43 | } |
44 | 44 | ||
45 | QString Connection::connectionMode() const { | 45 | QString ConnectionState::connectionMode() const { |
46 | return m_contype; | 46 | return m_contype; |
47 | } | 47 | } |
48 | 48 | ||
49 | void Connection::setMac( const QString& mac ) { | 49 | void ConnectionState::setMac( const QString& mac ) { |
50 | m_mac = mac; | 50 | m_mac = mac; |
51 | } | 51 | } |
52 | 52 | ||
53 | QString Connection::mac() const{ | 53 | QString ConnectionState::mac() const{ |
54 | return m_mac; | 54 | return m_mac; |
55 | } | 55 | } |
56 | 56 | ||
57 | void Connection::setHandle( int handle ) { | 57 | void ConnectionState::setHandle( int handle ) { |
58 | m_handle = handle; | 58 | m_handle = handle; |
59 | } | 59 | } |
60 | 60 | ||
61 | int Connection::handle() const{ | 61 | int ConnectionState::handle() const{ |
62 | return m_handle; | 62 | return m_handle; |
63 | } | 63 | } |
64 | 64 | ||
65 | void Connection::setState( int state ) { | 65 | void ConnectionState::setState( int state ) { |
66 | m_state = state; | 66 | m_state = state; |
67 | } | 67 | } |
68 | 68 | ||
69 | int Connection::state()const { | 69 | int ConnectionState::state()const { |
70 | return m_state; | 70 | return m_state; |
71 | } | 71 | } |
72 | 72 | ||
73 | void Connection::setLinkMode( int linkMode ) { | 73 | void ConnectionState::setLinkMode( int linkMode ) { |
74 | m_linkMode = linkMode; | 74 | m_linkMode = linkMode; |
75 | } | 75 | } |
76 | 76 | ||
77 | int Connection::linkMode()const{ | 77 | int ConnectionState::linkMode()const{ |
78 | return m_linkMode; | 78 | return m_linkMode; |
79 | } | 79 | } |
80 | 80 | ||
81 | Connection &Connection::operator=( const Connection& con1 ) { | 81 | ConnectionState &ConnectionState::operator=( const ConnectionState& con1 ) { |
82 | m_direction = con1.m_direction; | 82 | m_direction = con1.m_direction; |
83 | m_contype = con1.m_contype; | 83 | m_contype = con1.m_contype; |
84 | m_mac = con1.m_mac; | 84 | m_mac = con1.m_mac; |
85 | m_handle = con1.m_handle; | 85 | m_handle = con1.m_handle; |
86 | m_state = con1.m_state; | 86 | m_state = con1.m_state; |
87 | m_linkMode = con1.m_linkMode; | 87 | m_linkMode = con1.m_linkMode; |
88 | 88 | ||
89 | return (*this); | 89 | return (*this); |
90 | } | 90 | } |
diff --git a/noncore/net/opietooth/lib/connection.h b/noncore/net/opietooth/lib/connection.h index 37090ce..76e5dad 100644 --- a/noncore/net/opietooth/lib/connection.h +++ b/noncore/net/opietooth/lib/connection.h | |||
@@ -1,150 +1,150 @@ | |||
1 | 1 | ||
2 | #ifndef OpieTooth_Connection_H | 2 | #ifndef OpieTooth_Connection_H |
3 | #define OpieTooth_Connection_H | 3 | #define OpieTooth_Connection_H |
4 | 4 | ||
5 | #include <qstring.h> | 5 | #include <qstring.h> |
6 | #include <qvaluelist.h> | 6 | #include <qvaluelist.h> |
7 | 7 | ||
8 | namespace OpieTooth { | 8 | namespace OpieTooth { |
9 | 9 | ||
10 | enum LinkDirection { Incoming= true, Outgoing = false }; | 10 | enum LinkDirection { Incoming= true, Outgoing = false }; |
11 | enum LinkMode { Master =0, Client }; | 11 | enum LinkMode { Master =0, Client }; |
12 | 12 | ||
13 | 13 | ||
14 | /** | 14 | /** |
15 | * The Connection class stores | 15 | * The Connection class stores |
16 | * the output of hcitool con | 16 | * the output of hcitool con |
17 | * in a OO way | 17 | * in a OO way |
18 | */ | 18 | */ |
19 | 19 | ||
20 | class Connection { | 20 | class ConnectionState { |
21 | public: | 21 | public: |
22 | /** | 22 | /** |
23 | * typedef for a list of | 23 | * typedef for a list of |
24 | * Connections | 24 | * Connections |
25 | */ | 25 | */ |
26 | typedef QValueList<Connection> ValueList; | 26 | typedef QValueList<ConnectionState> ValueList; |
27 | 27 | ||
28 | /** | 28 | /** |
29 | * Copy c'tor. | 29 | * Copy c'tor. |
30 | */ | 30 | */ |
31 | Connection( const Connection& ); | 31 | ConnectionState( const ConnectionState& ); |
32 | 32 | ||
33 | /** | 33 | /** |
34 | * Main c'tor | 34 | * Main c'tor |
35 | * Basicly it holds all values | 35 | * Basicly it holds all values |
36 | * a blueZ connections can have | 36 | * a blueZ connections can have |
37 | * @param in If the connection is either incoming or outgoing | 37 | * @param in If the connection is either incoming or outgoing |
38 | * @param conType Either ACL or SCO for connection type | 38 | * @param conType Either ACL or SCO for connection type |
39 | * @param mac The BD Address( mac ) of the peer | 39 | * @param mac The BD Address( mac ) of the peer |
40 | * @param handle the blueZ handle | 40 | * @param handle the blueZ handle |
41 | * @param state the State of the connection | 41 | * @param state the State of the connection |
42 | * @param linkMode the linkmode of the connection MASTER or not | 42 | * @param linkMode the linkmode of the connection MASTER or not |
43 | * | 43 | * |
44 | * < ACL 00:02:C7:09:2B:53 handle 1 state 1 lm MASTER | 44 | * < ACL 00:02:C7:09:2B:53 handle 1 state 1 lm MASTER |
45 | * | 45 | * |
46 | */ | 46 | */ |
47 | Connection( bool in, | 47 | ConnectionState( bool in, |
48 | const QString& conType, | 48 | const QString& conType, |
49 | const QString& mac, | 49 | const QString& mac, |
50 | int handle, | 50 | int handle, |
51 | int state, | 51 | int state, |
52 | int linkMode ); | 52 | int linkMode ); |
53 | 53 | ||
54 | /** | 54 | /** |
55 | * C'tor for compability with QValueList | 55 | * C'tor for compability with QValueList |
56 | * QValueList needs this c'tor. | 56 | * QValueList needs this c'tor. |
57 | */ | 57 | */ |
58 | Connection(); | 58 | ConnectionState(); |
59 | 59 | ||
60 | /** | 60 | /** |
61 | * Set if the connection is incoming or | 61 | * Set if the connection is incoming or |
62 | * outgoing | 62 | * outgoing |
63 | * @param in Whether or not the connection is ingoing or not. | 63 | * @param in Whether or not the connection is ingoing or not. |
64 | * for param use either Incoming or Outgoing | 64 | * for param use either Incoming or Outgoing |
65 | * | 65 | * |
66 | */ | 66 | */ |
67 | void setDirection( bool incoming = Incoming ); | 67 | void setDirection( bool incoming = Incoming ); |
68 | 68 | ||
69 | /** | 69 | /** |
70 | * direction() will return Incoming( true ) | 70 | * direction() will return Incoming( true ) |
71 | * if the direction is incomoning or Outgoing( false) | 71 | * if the direction is incomoning or Outgoing( false) |
72 | * if outgoing | 72 | * if outgoing |
73 | */ | 73 | */ |
74 | bool direction() const; | 74 | bool direction() const; |
75 | 75 | ||
76 | /** | 76 | /** |
77 | * sets the ConnectionMode | 77 | * sets the ConnectionMode |
78 | * @param comMode I know that SCO and ACL exists so far | 78 | * @param comMode I know that SCO and ACL exists so far |
79 | */ | 79 | */ |
80 | void setConnectionMode( const QString& comMode ); | 80 | void setConnectionMode( const QString& comMode ); |
81 | 81 | ||
82 | /** | 82 | /** |
83 | * linkMode returns the linkMode | 83 | * linkMode returns the linkMode |
84 | * MASTER for example | 84 | * MASTER for example |
85 | */ | 85 | */ |
86 | QString connectionMode() const; | 86 | QString connectionMode() const; |
87 | 87 | ||
88 | /** | 88 | /** |
89 | * The Bluetooth Address or mac | 89 | * The Bluetooth Address or mac |
90 | * is set by this function | 90 | * is set by this function |
91 | * @param mac the BluetoothAddress( mac) | 91 | * @param mac the BluetoothAddress( mac) |
92 | */ | 92 | */ |
93 | void setMac( const QString& mac); | 93 | void setMac( const QString& mac); |
94 | 94 | ||
95 | /** | 95 | /** |
96 | * returns the mac | 96 | * returns the mac |
97 | */ | 97 | */ |
98 | QString mac() const; | 98 | QString mac() const; |
99 | 99 | ||
100 | 100 | ||
101 | /** | 101 | /** |
102 | * Set the handle of the bt connection | 102 | * Set the handle of the bt connection |
103 | */ | 103 | */ |
104 | void setHandle(int handle ); | 104 | void setHandle(int handle ); |
105 | 105 | ||
106 | /** | 106 | /** |
107 | * @return the handle of the connection | 107 | * @return the handle of the connection |
108 | */ | 108 | */ |
109 | int handle() const; | 109 | int handle() const; |
110 | 110 | ||
111 | /** | 111 | /** |
112 | * sets the state | 112 | * sets the state |
113 | */ | 113 | */ |
114 | void setState( int state ); | 114 | void setState( int state ); |
115 | 115 | ||
116 | /** | 116 | /** |
117 | * return the state | 117 | * return the state |
118 | */ | 118 | */ |
119 | int state() const; | 119 | int state() const; |
120 | 120 | ||
121 | /** | 121 | /** |
122 | * Sets the link mode of the Connection | 122 | * Sets the link mode of the Connection |
123 | */ | 123 | */ |
124 | void setLinkMode( int linkMode = Master ); | 124 | void setLinkMode( int linkMode = Master ); |
125 | 125 | ||
126 | /** | 126 | /** |
127 | * returns the linkMode | 127 | * returns the linkMode |
128 | */ | 128 | */ |
129 | int linkMode()const; | 129 | int linkMode()const; |
130 | 130 | ||
131 | /** | 131 | /** |
132 | * copy c'tor | 132 | * copy c'tor |
133 | */ | 133 | */ |
134 | Connection &operator=( const Connection& ); | 134 | ConnectionState &operator=( const ConnectionState& ); |
135 | 135 | ||
136 | private: | 136 | private: |
137 | class ConnectionPrivate; | 137 | class ConnectionStatePrivate; |
138 | ConnectionPrivate *d; | 138 | ConnectionStatePrivate *d; |
139 | bool m_direction : 1; | 139 | bool m_direction : 1; |
140 | QString m_contype; | 140 | QString m_contype; |
141 | QString m_mac; | 141 | QString m_mac; |
142 | int m_handle; | 142 | int m_handle; |
143 | int m_state; | 143 | int m_state; |
144 | int m_linkMode; | 144 | int m_linkMode; |
145 | 145 | ||
146 | }; | 146 | }; |
147 | }; | 147 | }; |
148 | 148 | ||
149 | 149 | ||
150 | #endif | 150 | #endif |
diff --git a/noncore/net/opietooth/lib/manager.cc b/noncore/net/opietooth/lib/manager.cc index e07f9da..1281116 100644 --- a/noncore/net/opietooth/lib/manager.cc +++ b/noncore/net/opietooth/lib/manager.cc | |||
@@ -129,171 +129,171 @@ QString Manager::toMac( const QString &/*device*/ ){ | |||
129 | } | 129 | } |
130 | void Manager::slotProcessExited(OProcess* proc ) { | 130 | void Manager::slotProcessExited(OProcess* proc ) { |
131 | bool conn= false; | 131 | bool conn= false; |
132 | if (proc->normalExit() && proc->exitStatus() == 0 ) | 132 | if (proc->normalExit() && proc->exitStatus() == 0 ) |
133 | conn = true; | 133 | conn = true; |
134 | 134 | ||
135 | QString name = QString::fromLatin1(proc->name() ); | 135 | QString name = QString::fromLatin1(proc->name() ); |
136 | emit available( name, conn ); | 136 | emit available( name, conn ); |
137 | delete proc; | 137 | delete proc; |
138 | } | 138 | } |
139 | void Manager::slotSDPOut(OProcess* proc, char* ch, int len) | 139 | void Manager::slotSDPOut(OProcess* proc, char* ch, int len) |
140 | { | 140 | { |
141 | QCString str(ch, len+1 ); | 141 | QCString str(ch, len+1 ); |
142 | qWarning("SDP:%s", str.data() ); | 142 | qWarning("SDP:%s", str.data() ); |
143 | QMap<QString, QString>::Iterator it; | 143 | QMap<QString, QString>::Iterator it; |
144 | it = m_out.find(proc->name() ); | 144 | it = m_out.find(proc->name() ); |
145 | QString string; | 145 | QString string; |
146 | if ( it != m_out.end() ) { | 146 | if ( it != m_out.end() ) { |
147 | string = it.data(); | 147 | string = it.data(); |
148 | } | 148 | } |
149 | string.append( str ); | 149 | string.append( str ); |
150 | m_out.replace( proc->name(), string ); | 150 | m_out.replace( proc->name(), string ); |
151 | 151 | ||
152 | } | 152 | } |
153 | void Manager::slotSDPExited( OProcess* proc) | 153 | void Manager::slotSDPExited( OProcess* proc) |
154 | { | 154 | { |
155 | qWarning("proc name %s", proc->name() ); | 155 | qWarning("proc name %s", proc->name() ); |
156 | Services::ValueList list; | 156 | Services::ValueList list; |
157 | if (proc->normalExit() ) { | 157 | if (proc->normalExit() ) { |
158 | QMap<QString, QString>::Iterator it = m_out.find( proc->name() ); | 158 | QMap<QString, QString>::Iterator it = m_out.find( proc->name() ); |
159 | if ( it != m_out.end() ) { | 159 | if ( it != m_out.end() ) { |
160 | qWarning("found process" ); | 160 | qWarning("found process" ); |
161 | list = parseSDPOutput( it.data() ); | 161 | list = parseSDPOutput( it.data() ); |
162 | m_out.remove( it ); | 162 | m_out.remove( it ); |
163 | } | 163 | } |
164 | } | 164 | } |
165 | emit foundServices( proc->name(), list ); | 165 | emit foundServices( proc->name(), list ); |
166 | delete proc; | 166 | delete proc; |
167 | } | 167 | } |
168 | Services::ValueList Manager::parseSDPOutput( const QString& out ) { | 168 | Services::ValueList Manager::parseSDPOutput( const QString& out ) { |
169 | Services::ValueList list; | 169 | Services::ValueList list; |
170 | qWarning("parsing output" ); | 170 | qWarning("parsing output" ); |
171 | Parser parser( out ); | 171 | Parser parser( out ); |
172 | list = parser.services(); | 172 | list = parser.services(); |
173 | return list; | 173 | return list; |
174 | } | 174 | } |
175 | 175 | ||
176 | void Manager::slotHCIExited(OProcess* proc ) { | 176 | void Manager::slotHCIExited(OProcess* proc ) { |
177 | qWarning("process exited"); | 177 | qWarning("process exited"); |
178 | RemoteDevice::ValueList list; | 178 | RemoteDevice::ValueList list; |
179 | if (proc->normalExit() ) { | 179 | if (proc->normalExit() ) { |
180 | qWarning("normalExit %s", proc->name() ); | 180 | qWarning("normalExit %s", proc->name() ); |
181 | QMap<QString, QString>::Iterator it = m_devices.find(proc->name() ); | 181 | QMap<QString, QString>::Iterator it = m_devices.find(proc->name() ); |
182 | if (it != m_devices.end() ) { | 182 | if (it != m_devices.end() ) { |
183 | qWarning("!= end ;)"); | 183 | qWarning("!= end ;)"); |
184 | list = parseHCIOutput( it.data() ); | 184 | list = parseHCIOutput( it.data() ); |
185 | m_devices.remove( it ); | 185 | m_devices.remove( it ); |
186 | } | 186 | } |
187 | } | 187 | } |
188 | emit foundDevices( proc->name(), list ); | 188 | emit foundDevices( proc->name(), list ); |
189 | delete proc; | 189 | delete proc; |
190 | } | 190 | } |
191 | void Manager::slotHCIOut(OProcess* proc, char* ch, int len) { | 191 | void Manager::slotHCIOut(OProcess* proc, char* ch, int len) { |
192 | QCString str( ch, len+1 ); | 192 | QCString str( ch, len+1 ); |
193 | qWarning("hci: %s", str.data() ); | 193 | qWarning("hci: %s", str.data() ); |
194 | QMap<QString, QString>::Iterator it; | 194 | QMap<QString, QString>::Iterator it; |
195 | it = m_devices.find( proc->name() ); | 195 | it = m_devices.find( proc->name() ); |
196 | qWarning("proc->name %s", proc->name() ); | 196 | qWarning("proc->name %s", proc->name() ); |
197 | QString string; | 197 | QString string; |
198 | if (it != m_devices.end() ) { | 198 | if (it != m_devices.end() ) { |
199 | qWarning("slotHCIOut "); | 199 | qWarning("slotHCIOut "); |
200 | string = it.data(); | 200 | string = it.data(); |
201 | } | 201 | } |
202 | string.append( str ); | 202 | string.append( str ); |
203 | 203 | ||
204 | m_devices.replace( proc->name(), string ); | 204 | m_devices.replace( proc->name(), string ); |
205 | } | 205 | } |
206 | RemoteDevice::ValueList Manager::parseHCIOutput(const QString& output ) { | 206 | RemoteDevice::ValueList Manager::parseHCIOutput(const QString& output ) { |
207 | qWarning("parseHCI %s", output.latin1() ); | 207 | qWarning("parseHCI %s", output.latin1() ); |
208 | RemoteDevice::ValueList list; | 208 | RemoteDevice::ValueList list; |
209 | QStringList strList = QStringList::split('\n', output ); | 209 | QStringList strList = QStringList::split('\n', output ); |
210 | QStringList::Iterator it; | 210 | QStringList::Iterator it; |
211 | QString str; | 211 | QString str; |
212 | for ( it = strList.begin(); it != strList.end(); ++it ) { | 212 | for ( it = strList.begin(); it != strList.end(); ++it ) { |
213 | str = (*it).stripWhiteSpace(); | 213 | str = (*it).stripWhiteSpace(); |
214 | qWarning("OpieTooth %s", str.latin1() ); | 214 | qWarning("OpieTooth %s", str.latin1() ); |
215 | int pos = str.findRev(':' ); | 215 | int pos = str.findRev(':' ); |
216 | if ( pos > 0 ) { | 216 | if ( pos > 0 ) { |
217 | QString mac = str.left(17 ); | 217 | QString mac = str.left(17 ); |
218 | str.remove( 0, 17 ); | 218 | str.remove( 0, 17 ); |
219 | qWarning("mac %s", mac.latin1() ); | 219 | qWarning("mac %s", mac.latin1() ); |
220 | qWarning("rest:%s", str.latin1() ); | 220 | qWarning("rest:%s", str.latin1() ); |
221 | RemoteDevice rem( mac , str.stripWhiteSpace() ); | 221 | RemoteDevice rem( mac , str.stripWhiteSpace() ); |
222 | list.append( rem ); | 222 | list.append( rem ); |
223 | } | 223 | } |
224 | } | 224 | } |
225 | return list; | 225 | return list; |
226 | } | 226 | } |
227 | 227 | ||
228 | ////// hcitool cc and hcitool con | 228 | ////// hcitool cc and hcitool con |
229 | 229 | ||
230 | /** | 230 | /** |
231 | * Create it on the stack as don't care | 231 | * Create it on the stack as don't care |
232 | * so we don't need to care for it | 232 | * so we don't need to care for it |
233 | * cause hcitool gets reparented | 233 | * cause hcitool gets reparented |
234 | */ | 234 | */ |
235 | void Manager::connectTo( const QString& mac) { | 235 | void Manager::connectTo( const QString& mac) { |
236 | OProcess proc; | 236 | OProcess proc; |
237 | proc << "hcitool"; | 237 | proc << "hcitool"; |
238 | proc << "cc"; | 238 | proc << "cc"; |
239 | proc << mac; | 239 | proc << mac; |
240 | proc.start(OProcess::DontCare); // the lib does not care at this point | 240 | proc.start(OProcess::DontCare); // the lib does not care at this point |
241 | } | 241 | } |
242 | 242 | ||
243 | 243 | ||
244 | void Manager::searchConnections() { | 244 | void Manager::searchConnections() { |
245 | qWarning("searching connections?"); | 245 | qWarning("searching connections?"); |
246 | OProcess* proc = new OProcess(); | 246 | OProcess* proc = new OProcess(); |
247 | m_hcitoolCon = QString::null; | 247 | m_hcitoolCon = QString::null; |
248 | 248 | ||
249 | connect(proc, SIGNAL(processExited(OProcess*) ), | 249 | connect(proc, SIGNAL(processExited(OProcess*) ), |
250 | this, SLOT(slotConnectionExited( OProcess*) ) ); | 250 | this, SLOT(slotConnectionExited( OProcess*) ) ); |
251 | connect(proc, SIGNAL(receivedStdout(OProcess*, char*, int) ), | 251 | connect(proc, SIGNAL(receivedStdout(OProcess*, char*, int) ), |
252 | this, SLOT(slotConnectionOutput(OProcess*, char*, int) ) ); | 252 | this, SLOT(slotConnectionOutput(OProcess*, char*, int) ) ); |
253 | *proc << "hcitool"; | 253 | *proc << "hcitool"; |
254 | *proc << "con"; | 254 | *proc << "con"; |
255 | 255 | ||
256 | if (!proc->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { | 256 | if (!proc->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { |
257 | Connection::ValueList list; | 257 | ConnectionState::ValueList list; |
258 | emit connections( list ); | 258 | emit connections( list ); |
259 | delete proc; | 259 | delete proc; |
260 | } | 260 | } |
261 | } | 261 | } |
262 | void Manager::slotConnectionExited( OProcess* /*proc*/ ) { | 262 | void Manager::slotConnectionExited( OProcess* /*proc*/ ) { |
263 | qWarning("exited"); | 263 | qWarning("exited"); |
264 | Connection::ValueList list; | 264 | ConnectionState::ValueList list; |
265 | list = parseConnections( m_hcitoolCon ); | 265 | list = parseConnections( m_hcitoolCon ); |
266 | emit connections(list ); | 266 | emit connections(list ); |
267 | } | 267 | } |
268 | void Manager::slotConnectionOutput(OProcess* proc, char* cha, int len) { | 268 | void Manager::slotConnectionOutput(OProcess* proc, char* cha, int len) { |
269 | QCString str(cha, len ); | 269 | QCString str(cha, len ); |
270 | m_hcitoolCon.append( str ); | 270 | m_hcitoolCon.append( str ); |
271 | delete proc; | 271 | delete proc; |
272 | } | 272 | } |
273 | Connection::ValueList Manager::parseConnections( const QString& out ) { | 273 | ConnectionState::ValueList Manager::parseConnections( const QString& out ) { |
274 | Connection::ValueList list2; | 274 | ConnectionState::ValueList list2; |
275 | QStringList list = QStringList::split('\n', out ); | 275 | QStringList list = QStringList::split('\n', out ); |
276 | QStringList::Iterator it; | 276 | QStringList::Iterator it; |
277 | for (it = list.begin(); it != list.end(); ++it ) { | 277 | for (it = list.begin(); it != list.end(); ++it ) { |
278 | QString row = (*it).stripWhiteSpace(); | 278 | QString row = (*it).stripWhiteSpace(); |
279 | QStringList value = QStringList::split(' ', row ); | 279 | QStringList value = QStringList::split(' ', row ); |
280 | qWarning("0: %s", value[0].latin1() ); | 280 | qWarning("0: %s", value[0].latin1() ); |
281 | qWarning("1: %s", value[1].latin1() ); | 281 | qWarning("1: %s", value[1].latin1() ); |
282 | qWarning("2: %s", value[2].latin1() ); | 282 | qWarning("2: %s", value[2].latin1() ); |
283 | qWarning("3: %s", value[3].latin1() ); | 283 | qWarning("3: %s", value[3].latin1() ); |
284 | qWarning("4: %s", value[4].latin1() ); | 284 | qWarning("4: %s", value[4].latin1() ); |
285 | qWarning("5: %s", value[5].latin1() ); | 285 | qWarning("5: %s", value[5].latin1() ); |
286 | qWarning("6: %s", value[6].latin1() ); | 286 | qWarning("6: %s", value[6].latin1() ); |
287 | qWarning("7: %s", value[7].latin1() ); | 287 | qWarning("7: %s", value[7].latin1() ); |
288 | qWarning("8: %s", value[8].latin1() ); | 288 | qWarning("8: %s", value[8].latin1() ); |
289 | Connection con; | 289 | ConnectionState con; |
290 | con.setDirection( value[0] == QString::fromLatin1("<") ? Outgoing : Incoming ); | 290 | con.setDirection( value[0] == QString::fromLatin1("<") ? Outgoing : Incoming ); |
291 | con.setConnectionMode( value[1] ); | 291 | con.setConnectionMode( value[1] ); |
292 | con.setMac( value[2] ); | 292 | con.setMac( value[2] ); |
293 | con.setHandle( value[4].toInt() ); | 293 | con.setHandle( value[4].toInt() ); |
294 | con.setState( value[6].toInt() ); | 294 | con.setState( value[6].toInt() ); |
295 | con.setLinkMode( value[8] == QString::fromLatin1("MASTER") ? Master : Client ); | 295 | con.setLinkMode( value[8] == QString::fromLatin1("MASTER") ? Master : Client ); |
296 | list2.append( con ); | 296 | list2.append( con ); |
297 | } | 297 | } |
298 | return list2; | 298 | return list2; |
299 | } | 299 | } |
diff --git a/noncore/net/opietooth/lib/manager.h b/noncore/net/opietooth/lib/manager.h index b32327c..0ebe1b3 100644 --- a/noncore/net/opietooth/lib/manager.h +++ b/noncore/net/opietooth/lib/manager.h | |||
@@ -12,155 +12,155 @@ | |||
12 | #include "services.h" | 12 | #include "services.h" |
13 | 13 | ||
14 | class OProcess; | 14 | class OProcess; |
15 | namespace OpieTooth { | 15 | namespace OpieTooth { |
16 | class Device; | 16 | class Device; |
17 | /** Manager manages a blueZ device (hci0 for example) | 17 | /** Manager manages a blueZ device (hci0 for example) |
18 | * without Manager you can control the things you | 18 | * without Manager you can control the things you |
19 | * could do from command line in a OO and asynchronus | 19 | * could do from command line in a OO and asynchronus |
20 | * way. | 20 | * way. |
21 | */ | 21 | */ |
22 | class Manager : public QObject { | 22 | class Manager : public QObject { |
23 | Q_OBJECT | 23 | Q_OBJECT |
24 | public: | 24 | public: |
25 | /** c'tor whichs create a new Manager | 25 | /** c'tor whichs create a new Manager |
26 | * @param device is the device to use. Either a mac or blueZ device name | 26 | * @param device is the device to use. Either a mac or blueZ device name |
27 | * | 27 | * |
28 | */ | 28 | */ |
29 | Manager( const QString &device ); | 29 | Manager( const QString &device ); |
30 | 30 | ||
31 | /** c'tor | 31 | /** c'tor |
32 | * @param dev The Device to be managed | 32 | * @param dev The Device to be managed |
33 | * We don't care of Device so you need to delete it | 33 | * We don't care of Device so you need to delete it |
34 | */ | 34 | */ |
35 | Manager( Device* dev ); | 35 | Manager( Device* dev ); |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * c'tor | 38 | * c'tor |
39 | */ | 39 | */ |
40 | Manager(); | 40 | Manager(); |
41 | 41 | ||
42 | ~Manager(); | 42 | ~Manager(); |
43 | 43 | ||
44 | /** Set the manager to control a new device | 44 | /** Set the manager to control a new device |
45 | * @param device the new device to control (hci0 ) | 45 | * @param device the new device to control (hci0 ) |
46 | */ | 46 | */ |
47 | void setDevice( const QString& device ); | 47 | void setDevice( const QString& device ); |
48 | 48 | ||
49 | /** | 49 | /** |
50 | * Convience functions for setting a new device | 50 | * Convience functions for setting a new device |
51 | */ | 51 | */ |
52 | void setDevice( Device *dev ); | 52 | void setDevice( Device *dev ); |
53 | 53 | ||
54 | /** | 54 | /** |
55 | * Wether or not a device is connected. The function | 55 | * Wether or not a device is connected. The function |
56 | * is asynchron | 56 | * is asynchron |
57 | * If device is empty it will take the currently managed | 57 | * If device is empty it will take the currently managed |
58 | * device and see if it's up | 58 | * device and see if it's up |
59 | * for Remote devices it will ping and see. | 59 | * for Remote devices it will ping and see. |
60 | * @param either mac or hciX | 60 | * @param either mac or hciX |
61 | */ | 61 | */ |
62 | void isAvailable(const QString& device= QString::null ); | 62 | void isAvailable(const QString& device= QString::null ); |
63 | 63 | ||
64 | /** | 64 | /** |
65 | * same as above | 65 | * same as above |
66 | */ | 66 | */ |
67 | void isAvailable(Device *dev ); | 67 | void isAvailable(Device *dev ); |
68 | 68 | ||
69 | /** this searchs for devices reachable from the | 69 | /** this searchs for devices reachable from the |
70 | * currently managed device | 70 | * currently managed device |
71 | * or from device if @param device is not empty | 71 | * or from device if @param device is not empty |
72 | */ | 72 | */ |
73 | void searchDevices(const QString& device= QString::null ); | 73 | void searchDevices(const QString& device= QString::null ); |
74 | /** same as above | 74 | /** same as above |
75 | * | 75 | * |
76 | */ | 76 | */ |
77 | void searchDevices(Device *d ); | 77 | void searchDevices(Device *d ); |
78 | 78 | ||
79 | /** | 79 | /** |
80 | * This will add the service @param name | 80 | * This will add the service @param name |
81 | * to the sdpd daemon | 81 | * to the sdpd daemon |
82 | * It will start the daemon if necessary | 82 | * It will start the daemon if necessary |
83 | */ | 83 | */ |
84 | void addService(const QString &name ); | 84 | void addService(const QString &name ); |
85 | 85 | ||
86 | /** | 86 | /** |
87 | * This will add the services @param names | 87 | * This will add the services @param names |
88 | * to the sdpd daemon | 88 | * to the sdpd daemon |
89 | * It will start the daemon if necessary | 89 | * It will start the daemon if necessary |
90 | */ | 90 | */ |
91 | void addServices( const QStringList& names ); | 91 | void addServices( const QStringList& names ); |
92 | 92 | ||
93 | /** | 93 | /** |
94 | * This removes a service from the sdps | 94 | * This removes a service from the sdps |
95 | */ | 95 | */ |
96 | void removeService(const QString &name ); | 96 | void removeService(const QString &name ); |
97 | 97 | ||
98 | /** | 98 | /** |
99 | * Removes a list from the sdpd | 99 | * Removes a list from the sdpd |
100 | */ | 100 | */ |
101 | void removeServices(const QStringList& ); | 101 | void removeServices(const QStringList& ); |
102 | 102 | ||
103 | /** | 103 | /** |
104 | * search for services on a remote device | 104 | * search for services on a remote device |
105 | * | 105 | * |
106 | */ | 106 | */ |
107 | void searchServices( const QString& remDevice ); | 107 | void searchServices( const QString& remDevice ); |
108 | 108 | ||
109 | /** | 109 | /** |
110 | * search for services on a remote device | 110 | * search for services on a remote device |
111 | */ | 111 | */ |
112 | void searchServices( const RemoteDevice& ); | 112 | void searchServices( const RemoteDevice& ); |
113 | 113 | ||
114 | /** | 114 | /** |
115 | * Starts to connect to the device | 115 | * Starts to connect to the device |
116 | * in @param | 116 | * in @param |
117 | */ | 117 | */ |
118 | void connectTo(const QString& ); | 118 | void connectTo(const QString& ); |
119 | 119 | ||
120 | /** | 120 | /** |
121 | * Searches for active connections | 121 | * Searches for active connections |
122 | * the result is emitted with the | 122 | * the result is emitted with the |
123 | * connections signal | 123 | * connections signal |
124 | */ | 124 | */ |
125 | void searchConnections(); | 125 | void searchConnections(); |
126 | 126 | ||
127 | //// not implemented yet | 127 | //// not implemented yet |
128 | /*static*/ QString toDevice( const QString& mac ); | 128 | /*static*/ QString toDevice( const QString& mac ); |
129 | /*static*/ QString toMac( const QString &device ); | 129 | /*static*/ QString toMac( const QString &device ); |
130 | //// not implemented yet over | 130 | //// not implemented yet over |
131 | 131 | ||
132 | signals: | 132 | signals: |
133 | // device either mac or dev name | 133 | // device either mac or dev name |
134 | // the first device is the device which you access | 134 | // the first device is the device which you access |
135 | void available( const QString& device, bool connected ); | 135 | void available( const QString& device, bool connected ); |
136 | void addedService( const QString& service, bool added ); | 136 | void addedService( const QString& service, bool added ); |
137 | void removedService( const QString& service, bool removed ); | 137 | void removedService( const QString& service, bool removed ); |
138 | void foundServices( const QString& device, Services::ValueList ); | 138 | void foundServices( const QString& device, Services::ValueList ); |
139 | void foundDevices( const QString& device, RemoteDevice::ValueList ); | 139 | void foundDevices( const QString& device, RemoteDevice::ValueList ); |
140 | void connections( Connection::ValueList ); | 140 | void connections( ConnectionState::ValueList ); |
141 | 141 | ||
142 | private slots: | 142 | private slots: |
143 | void slotProcessExited(OProcess* ); | 143 | void slotProcessExited(OProcess* ); |
144 | 144 | ||
145 | void slotSDPExited(OProcess*); | 145 | void slotSDPExited(OProcess*); |
146 | void slotSDPOut(OProcess*, char*, int); | 146 | void slotSDPOut(OProcess*, char*, int); |
147 | 147 | ||
148 | void slotHCIExited(OProcess* ); | 148 | void slotHCIExited(OProcess* ); |
149 | void slotHCIOut(OProcess*, char*, int ); | 149 | void slotHCIOut(OProcess*, char*, int ); |
150 | 150 | ||
151 | void slotConnectionExited(OProcess* ); | 151 | void slotConnectionExited(OProcess* ); |
152 | void slotConnectionOutput(OProcess*, char*, int ); | 152 | void slotConnectionOutput(OProcess*, char*, int ); |
153 | private: | 153 | private: |
154 | Services::ValueList parseSDPOutput( const QString& ); | 154 | Services::ValueList parseSDPOutput( const QString& ); |
155 | RemoteDevice::ValueList parseHCIOutput( const QString& ); | 155 | RemoteDevice::ValueList parseHCIOutput( const QString& ); |
156 | Connection::ValueList parseConnections( const QString& ); | 156 | ConnectionState::ValueList parseConnections( const QString& ); |
157 | OProcess *m_hcitool; | 157 | OProcess *m_hcitool; |
158 | OProcess *m_sdp; // not only one | 158 | OProcess *m_sdp; // not only one |
159 | QString m_device; | 159 | QString m_device; |
160 | QMap<QString, QString> m_out; | 160 | QMap<QString, QString> m_out; |
161 | QMap<QString, QString> m_devices; | 161 | QMap<QString, QString> m_devices; |
162 | QString m_hcitoolCon; | 162 | QString m_hcitoolCon; |
163 | }; | 163 | }; |
164 | }; | 164 | }; |
165 | 165 | ||
166 | #endif | 166 | #endif |
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index 85c6717..9cfeaa2 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp | |||
@@ -1,458 +1,476 @@ | |||
1 | /* | 1 | /* |
2 | * bluebase.cpp * | 2 | * bluebase.cpp * |
3 | * --------------------- | 3 | * --------------------- |
4 | * | 4 | * |
5 | * copyright : (c) 2002 by Maximilian Reiß | 5 | * copyright : (c) 2002 by Maximilian Reiß |
6 | * email : max.reiss@gmx.de | 6 | * email : max.reiss@gmx.de |
7 | * | 7 | * |
8 | */ | 8 | */ |
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * (at your option) any later version. * | 14 | * (at your option) any later version. * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | #include "bluebase.h" | 18 | #include "bluebase.h" |
19 | #include "scandialog.h" | 19 | #include "scandialog.h" |
20 | #include "hciconfwrapper.h" | 20 | #include "hciconfwrapper.h" |
21 | 21 | ||
22 | #include <qframe.h> | 22 | #include <qframe.h> |
23 | #include <qlabel.h> | 23 | #include <qlabel.h> |
24 | #include <qpushbutton.h> | 24 | #include <qpushbutton.h> |
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | #include <qvariant.h> | 26 | #include <qvariant.h> |
27 | #include <qwhatsthis.h> | 27 | #include <qwhatsthis.h> |
28 | #include <qimage.h> | 28 | #include <qimage.h> |
29 | #include <qpixmap.h> | 29 | #include <qpixmap.h> |
30 | #include <qtabwidget.h> | 30 | #include <qtabwidget.h> |
31 | #include <qscrollview.h> | 31 | #include <qscrollview.h> |
32 | #include <qvbox.h> | 32 | #include <qvbox.h> |
33 | #include <qmessagebox.h> | 33 | #include <qmessagebox.h> |
34 | #include <qcheckbox.h> | 34 | #include <qcheckbox.h> |
35 | #include <qlineedit.h> | 35 | #include <qlineedit.h> |
36 | #include <qlistview.h> | 36 | #include <qlistview.h> |
37 | #include <qdir.h> | 37 | #include <qdir.h> |
38 | #include <qpopupmenu.h> | 38 | #include <qpopupmenu.h> |
39 | #include <qtimer.h> | 39 | #include <qtimer.h> |
40 | 40 | ||
41 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
42 | #include <qpe/config.h> | 42 | #include <qpe/config.h> |
43 | 43 | ||
44 | #include <remotedevice.h> | 44 | #include <remotedevice.h> |
45 | #include <services.h> | 45 | #include <services.h> |
46 | 46 | ||
47 | #include "btconnectionitem.h" | ||
48 | |||
47 | using namespace OpieTooth; | 49 | using namespace OpieTooth; |
48 | 50 | ||
49 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) | 51 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) |
50 | : BluetoothBase( parent, name, fl ) { | 52 | : BluetoothBase( parent, name, fl ) { |
51 | 53 | ||
52 | m_localDevice = new Manager( "hci0" ); | 54 | m_localDevice = new Manager( "hci0" ); |
53 | 55 | ||
54 | connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); | 56 | connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); |
55 | connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); | 57 | connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); |
56 | // not good since lib is async | 58 | // not good since lib is async |
57 | // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), | 59 | // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), |
58 | // this, SLOT( addServicesToDevice( QListViewItem * ) ) ); | 60 | // this, SLOT( addServicesToDevice( QListViewItem * ) ) ); |
59 | connect( ListView2, SIGNAL( clicked( QListViewItem* )), | 61 | connect( ListView2, SIGNAL( clicked( QListViewItem* )), |
60 | this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); | 62 | this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); |
61 | connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), | 63 | connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), |
62 | this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); | 64 | this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); |
63 | connect( m_localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), | 65 | connect( m_localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), |
64 | this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); | 66 | this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); |
65 | connect( m_localDevice, SIGNAL( available( const QString&, bool ) ), | 67 | connect( m_localDevice, SIGNAL( available( const QString&, bool ) ), |
66 | this, SLOT( deviceActive( const QString& , bool ) ) ); | 68 | this, SLOT( deviceActive( const QString& , bool ) ) ); |
67 | connect( m_localDevice, SIGNAL( connections( Connection::ValueList ) ), | 69 | connect( m_localDevice, SIGNAL( connections( Connection::ValueList ) ), |
68 | this, SLOT( addConnectedDevices( Connection::ValueList ) ) ); | 70 | this, SLOT( addConnectedDevices( Connection::ValueList ) ) ); |
69 | 71 | ||
70 | //Load all icons needed | 72 | //Load all icons needed |
71 | m_offPix = Resource::loadPixmap( "editdelete" ); | 73 | m_offPix = Resource::loadPixmap( "editdelete" ); |
72 | m_onPix = Resource::loadPixmap( "installed" ); | 74 | m_onPix = Resource::loadPixmap( "installed" ); |
73 | 75 | ||
74 | QPalette pal = this->palette(); | 76 | QPalette pal = this->palette(); |
75 | QColor col = pal.color( QPalette::Active, QColorGroup::Background ); | 77 | QColor col = pal.color( QPalette::Active, QColorGroup::Background ); |
76 | pal.setColor( QPalette::Active, QColorGroup::Button, col ); | 78 | pal.setColor( QPalette::Active, QColorGroup::Button, col ); |
77 | pal.setColor( QPalette::Inactive, QColorGroup::Button, col ); | 79 | pal.setColor( QPalette::Inactive, QColorGroup::Button, col ); |
78 | pal.setColor( QPalette::Normal, QColorGroup::Button, col ); | 80 | pal.setColor( QPalette::Normal, QColorGroup::Button, col ); |
79 | pal.setColor( QPalette::Disabled, QColorGroup::Button, col ); | 81 | pal.setColor( QPalette::Disabled, QColorGroup::Button, col ); |
80 | this->setPalette( pal ); | 82 | this->setPalette( pal ); |
81 | 83 | ||
82 | setCaption( tr( "Bluetooth Manager" ) ); | 84 | setCaption( tr( "Bluetooth Manager" ) ); |
83 | 85 | ||
84 | readConfig(); | 86 | readConfig(); |
85 | initGui(); | 87 | initGui(); |
86 | 88 | ||
87 | //TESTING | 89 | //TESTING |
88 | ListView2->setRootIsDecorated(true); | 90 | ListView2->setRootIsDecorated(true); |
89 | 91 | ||
90 | BTListItem *topLV2 = new BTListItem( ListView2, "Siemens S45", "", "device" ); | 92 | BTDeviceItem *topLV2 = new BTDeviceItem( ListView2, RemoteDevice("xx:", "Siemens S45" ) ); |
91 | topLV2->setPixmap( 1, m_onPix ); | 93 | topLV2->setPixmap( 1, m_onPix ); |
92 | (void) new BTListItem( topLV2, "Serial" ,"", "service" ); | 94 | Services s1; |
93 | (void) new BTListItem( topLV2, "BlueNiC" , "", "service" ); | 95 | s1.setServiceName( "Serial" ); |
96 | (void) new BTServiceItem( topLV2, s1 ); | ||
97 | s1.setServiceName( "BlueNic" ); | ||
98 | (void) new BTServiceItem( topLV2, s1 ); | ||
94 | 99 | ||
95 | writeToHciConfig(); | 100 | writeToHciConfig(); |
96 | // search conncetions | 101 | // search conncetions |
97 | addConnectedDevices(); | 102 | addConnectedDevices(); |
98 | m_iconLoader = new BTIconLoader(); | 103 | m_iconLoader = new BTIconLoader(); |
99 | } | 104 | } |
100 | 105 | ||
101 | /** | 106 | /** |
102 | * Reads all options from the config file | 107 | * Reads all options from the config file |
103 | */ | 108 | */ |
104 | void BlueBase::readConfig() { | 109 | void BlueBase::readConfig() { |
105 | 110 | ||
106 | Config cfg( "bluetoothmanager" ); | 111 | Config cfg( "bluetoothmanager" ); |
107 | cfg.setGroup( "bluezsettings" ); | 112 | cfg.setGroup( "bluezsettings" ); |
108 | 113 | ||
109 | m_deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with | 114 | m_deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with |
110 | m_defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak | 115 | m_defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak |
111 | m_useEncryption = cfg.readBoolEntry( "useEncryption" , TRUE ); | 116 | m_useEncryption = cfg.readBoolEntry( "useEncryption" , TRUE ); |
112 | m_enableAuthentification = cfg.readBoolEntry( "enableAuthentification" , TRUE ); | 117 | m_enableAuthentification = cfg.readBoolEntry( "enableAuthentification" , TRUE ); |
113 | m_enablePagescan = cfg.readBoolEntry( "enablePagescan" , TRUE ); | 118 | m_enablePagescan = cfg.readBoolEntry( "enablePagescan" , TRUE ); |
114 | m_enableInquiryscan = cfg.readBoolEntry( "enableInquiryscan" , TRUE ); | 119 | m_enableInquiryscan = cfg.readBoolEntry( "enableInquiryscan" , TRUE ); |
115 | } | 120 | } |
116 | 121 | ||
117 | /** | 122 | /** |
118 | * Writes all options to the config file | 123 | * Writes all options to the config file |
119 | */ | 124 | */ |
120 | void BlueBase::writeConfig() { | 125 | void BlueBase::writeConfig() { |
121 | 126 | ||
122 | Config cfg( "bluetoothmanager" ); | 127 | Config cfg( "bluetoothmanager" ); |
123 | cfg.setGroup( "bluezsettings" ); | 128 | cfg.setGroup( "bluezsettings" ); |
124 | 129 | ||
125 | cfg.writeEntry( "name" , m_deviceName ); | 130 | cfg.writeEntry( "name" , m_deviceName ); |
126 | cfg.writeEntryCrypt( "passkey" , m_defaultPasskey ); | 131 | cfg.writeEntryCrypt( "passkey" , m_defaultPasskey ); |
127 | cfg.writeEntry( "useEncryption" , m_useEncryption ); | 132 | cfg.writeEntry( "useEncryption" , m_useEncryption ); |
128 | cfg.writeEntry( "enableAuthentification" , m_enableAuthentification ); | 133 | cfg.writeEntry( "enableAuthentification" , m_enableAuthentification ); |
129 | cfg.writeEntry( "enablePagescan" , m_enablePagescan ); | 134 | cfg.writeEntry( "enablePagescan" , m_enablePagescan ); |
130 | cfg.writeEntry( "enableInquiryscan" , m_enableInquiryscan ); | 135 | cfg.writeEntry( "enableInquiryscan" , m_enableInquiryscan ); |
131 | 136 | ||
132 | writeToHciConfig(); | 137 | writeToHciConfig(); |
133 | } | 138 | } |
134 | 139 | ||
135 | void BlueBase::writeToHciConfig() { | 140 | void BlueBase::writeToHciConfig() { |
136 | 141 | ||
137 | HciConfWrapper hciconf ( "/tmp/hcid.conf" ); | 142 | HciConfWrapper hciconf ( "/tmp/hcid.conf" ); |
138 | hciconf.setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); | 143 | hciconf.setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); |
139 | 144 | ||
140 | 145 | ||
141 | // hciconf->setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); | 146 | // hciconf->setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); |
142 | 147 | ||
143 | hciconf.setName( m_deviceName ); | 148 | hciconf.setName( m_deviceName ); |
144 | hciconf.setEncrypt( m_useEncryption ); | 149 | hciconf.setEncrypt( m_useEncryption ); |
145 | hciconf.setAuth( m_enableAuthentification ); | 150 | hciconf.setAuth( m_enableAuthentification ); |
146 | hciconf.setPscan( m_enablePagescan ); | 151 | hciconf.setPscan( m_enablePagescan ); |
147 | hciconf.setIscan( m_enableInquiryscan ); | 152 | hciconf.setIscan( m_enableInquiryscan ); |
148 | } | 153 | } |
149 | 154 | ||
150 | 155 | ||
151 | /** | 156 | /** |
152 | * Read the list of allready known devices | 157 | * Read the list of allready known devices |
153 | * | 158 | * |
154 | */ | 159 | */ |
155 | void BlueBase::readSavedDevices() { | 160 | void BlueBase::readSavedDevices() { |
156 | 161 | ||
157 | QValueList<RemoteDevice> loadedDevices; | 162 | QValueList<RemoteDevice> loadedDevices; |
158 | 163 | ||
159 | QDir deviceListSave( QDir::homeDirPath() + "/Settings/bluetooth/"); | 164 | QDir deviceListSave( QDir::homeDirPath() + "/Settings/bluetooth/"); |
160 | // list of .conf files | 165 | // list of .conf files |
161 | QStringList devicesFileList = deviceListSave.entryList(); | 166 | QStringList devicesFileList = deviceListSave.entryList(); |
162 | 167 | ||
163 | // cut .conf of to get the mac and also read the name entry in it. | 168 | // cut .conf of to get the mac and also read the name entry in it. |
164 | 169 | ||
165 | for ( QStringList::Iterator it = devicesFileList.begin(); it != devicesFileList.end(); ++it ) { | 170 | for ( QStringList::Iterator it = devicesFileList.begin(); it != devicesFileList.end(); ++it ) { |
166 | 171 | ||
167 | QString name; | 172 | QString name; |
168 | QString mac; | 173 | QString mac; |
169 | qDebug((*it).latin1() ); | 174 | qDebug((*it).latin1() ); |
170 | Config conf((*it)); | 175 | Config conf((*it)); |
171 | conf.setGroup("Info"); | 176 | conf.setGroup("Info"); |
172 | name = conf.readEntry("name", "Error"); | 177 | name = conf.readEntry("name", "Error"); |
173 | qDebug("MAC: " + mac); | 178 | qDebug("MAC: " + mac); |
174 | qDebug("NAME: " + name); | 179 | qDebug("NAME: " + name); |
175 | RemoteDevice currentDevice( mac , name ); | 180 | RemoteDevice currentDevice( mac , name ); |
176 | loadedDevices.append( currentDevice ); | 181 | loadedDevices.append( currentDevice ); |
177 | } | 182 | } |
178 | addSearchedDevices( loadedDevices ); | 183 | addSearchedDevices( loadedDevices ); |
179 | } | 184 | } |
180 | 185 | ||
181 | /** | 186 | /** |
182 | * Write the list of allready known devices | 187 | * Write the list of allready known devices |
183 | * | 188 | * |
184 | */ | 189 | */ |
185 | void BlueBase::writeSavedDevices() { | 190 | void BlueBase::writeSavedDevices() { |
186 | QListViewItemIterator it( ListView2 ); | 191 | QListViewItemIterator it( ListView2 ); |
192 | BTListItem* item; | ||
193 | BTDeviceItem* device; | ||
187 | 194 | ||
188 | for ( ; it.current(); ++it ) { | 195 | for ( ; it.current(); ++it ) { |
196 | item = (BTListItem*)it.current(); | ||
197 | if(item->typeId() != BTListItem::Device ) | ||
198 | continue; | ||
199 | device = (BTDeviceItem*)item; | ||
189 | // seperate config file for each device, to store more information in future. | 200 | // seperate config file for each device, to store more information in future. |
190 | qDebug( "/Settings/bluetooth/" + (((BTListItem*)it.current())->mac()) + ".conf"); | 201 | qDebug( "/Settings/bluetooth/" + device->mac() + ".conf"); |
191 | Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + (((BTListItem*)it.current())->mac()) + ".conf", Config::File ); | 202 | Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + device->mac() + ".conf", Config::File ); |
192 | conf.setGroup( "Info" ); | 203 | conf.setGroup( "Info" ); |
193 | conf.writeEntry( "name", ((BTListItem*)it.current())->name() ); | 204 | conf.writeEntry( "name", device->name() ); |
194 | } | 205 | } |
195 | } | 206 | } |
196 | 207 | ||
197 | 208 | ||
198 | /** | 209 | /** |
199 | * Set up the gui | 210 | * Set up the gui |
200 | */ | 211 | */ |
201 | void BlueBase::initGui() { | 212 | void BlueBase::initGui() { |
202 | StatusLabel->setText( status() ); // maybe move it to getStatus() | 213 | StatusLabel->setText( status() ); // maybe move it to getStatus() |
203 | cryptCheckBox->setChecked( m_useEncryption ); | 214 | cryptCheckBox->setChecked( m_useEncryption ); |
204 | authCheckBox->setChecked( m_enableAuthentification ); | 215 | authCheckBox->setChecked( m_enableAuthentification ); |
205 | pagescanCheckBox->setChecked( m_enablePagescan ); | 216 | pagescanCheckBox->setChecked( m_enablePagescan ); |
206 | inquiryscanCheckBox->setChecked( m_enableInquiryscan ); | 217 | inquiryscanCheckBox->setChecked( m_enableInquiryscan ); |
207 | deviceNameLine->setText( m_deviceName ); | 218 | deviceNameLine->setText( m_deviceName ); |
208 | passkeyLine->setText( m_defaultPasskey ); | 219 | passkeyLine->setText( m_defaultPasskey ); |
209 | // set info tab | 220 | // set info tab |
210 | setInfo(); | 221 | setInfo(); |
211 | } | 222 | } |
212 | 223 | ||
213 | 224 | ||
214 | /** | 225 | /** |
215 | * Get the status informations and returns it | 226 | * Get the status informations and returns it |
216 | * @return QString the status informations gathered | 227 | * @return QString the status informations gathered |
217 | */ | 228 | */ |
218 | QString BlueBase::status()const{ | 229 | QString BlueBase::status()const{ |
219 | QString infoString = tr( "<b>Device name : </b> Ipaq" ); | 230 | QString infoString = tr( "<b>Device name : </b> Ipaq" ); |
220 | infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); | 231 | infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); |
221 | infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); | 232 | infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); |
222 | 233 | ||
223 | return (infoString); | 234 | return (infoString); |
224 | } | 235 | } |
225 | 236 | ||
226 | 237 | ||
227 | /** | 238 | /** |
228 | * Read the current values from the gui and invoke writeConfig() | 239 | * Read the current values from the gui and invoke writeConfig() |
229 | */ | 240 | */ |
230 | void BlueBase::applyConfigChanges() { | 241 | void BlueBase::applyConfigChanges() { |
231 | m_deviceName = deviceNameLine->text(); | 242 | m_deviceName = deviceNameLine->text(); |
232 | m_defaultPasskey = passkeyLine->text(); | 243 | m_defaultPasskey = passkeyLine->text(); |
233 | m_useEncryption = cryptCheckBox->isChecked(); | 244 | m_useEncryption = cryptCheckBox->isChecked(); |
234 | m_enableAuthentification = authCheckBox->isChecked(); | 245 | m_enableAuthentification = authCheckBox->isChecked(); |
235 | m_enablePagescan = pagescanCheckBox->isChecked(); | 246 | m_enablePagescan = pagescanCheckBox->isChecked(); |
236 | m_enableInquiryscan = inquiryscanCheckBox->isChecked(); | 247 | m_enableInquiryscan = inquiryscanCheckBox->isChecked(); |
237 | 248 | ||
238 | writeConfig(); | 249 | writeConfig(); |
239 | 250 | ||
240 | QMessageBox::information( this, tr("Test") , tr("Changes were applied.") ); | 251 | QMessageBox::information( this, tr("Test") , tr("Changes were applied.") ); |
241 | } | 252 | } |
242 | 253 | ||
243 | /** | 254 | /** |
244 | * Add fresh found devices from scan dialog to the listing | 255 | * Add fresh found devices from scan dialog to the listing |
245 | * | 256 | * |
246 | */ | 257 | */ |
247 | void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) { | 258 | void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) { |
248 | BTListItem * deviceItem; | 259 | BTDeviceItem * deviceItem; |
249 | QValueList<RemoteDevice>::ConstIterator it; | 260 | QValueList<RemoteDevice>::ConstIterator it; |
250 | 261 | ||
251 | for( it = newDevices.begin(); it != newDevices.end() ; ++it ) { | 262 | for( it = newDevices.begin(); it != newDevices.end() ; ++it ) { |
252 | deviceItem = new BTListItem( ListView2 , (*it).name(), (*it).mac(), "device" ); | 263 | |
264 | deviceItem = new BTDeviceItem( ListView2 , (*it) ); | ||
253 | deviceItem->setExpandable ( true ); | 265 | deviceItem->setExpandable ( true ); |
254 | 266 | ||
255 | // look if device is avail. atm, async | 267 | // look if device is avail. atm, async |
256 | deviceActive( (*it) ); | 268 | deviceActive( (*it) ); |
257 | 269 | ||
258 | // ggf auch hier? | 270 | // ggf auch hier? |
259 | addServicesToDevice( deviceItem ); | 271 | addServicesToDevice( deviceItem ); |
260 | } | 272 | } |
261 | } | 273 | } |
262 | 274 | ||
263 | 275 | ||
264 | /** | 276 | /** |
265 | * Action that is toggled on entrys on click | 277 | * Action that is toggled on entrys on click |
266 | */ | 278 | */ |
267 | void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) { | 279 | void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) { |
268 | } | 280 | } |
269 | 281 | ||
270 | /** | 282 | /** |
271 | * Action that are toggled on hold (mostly QPopups i guess) | 283 | * Action that are toggled on hold (mostly QPopups i guess) |
272 | */ | 284 | */ |
273 | void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) { | 285 | void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) { |
274 | 286 | ||
275 | QPopupMenu *menu = new QPopupMenu(); | 287 | QPopupMenu *menu = new QPopupMenu(); |
276 | int ret=0; | 288 | int ret=0; |
277 | 289 | ||
278 | if ( ((BTListItem*)item)->type() == "device") { | 290 | if ( ((BTListItem*)item)->type() == "device") { |
279 | 291 | ||
280 | QPopupMenu *groups = new QPopupMenu(); | 292 | QPopupMenu *groups = new QPopupMenu(); |
281 | 293 | ||
282 | menu->insertItem( tr("rescan sevices:"), 0); | 294 | menu->insertItem( tr("rescan sevices:"), 0); |
283 | menu->insertItem( tr("to group"), groups , 1); | 295 | menu->insertItem( tr("to group"), groups , 1); |
284 | menu->insertItem( tr("bound device"), 2); | 296 | menu->insertItem( tr("bound device"), 2); |
285 | menu->insertItem( tr("delete"), 3); | 297 | menu->insertItem( tr("delete"), 3); |
286 | 298 | ||
287 | ret = menu->exec( point , 0); | 299 | ret = menu->exec( point , 0); |
288 | 300 | ||
289 | switch(ret) { | 301 | switch(ret) { |
290 | case 0: | 302 | case 0: |
291 | break; | 303 | break; |
292 | case 1: | 304 | case 1: |
293 | break; | 305 | break; |
294 | case 2: | 306 | case 2: |
295 | // make connection | 307 | // make connection |
296 | break; | 308 | break; |
297 | case 3: | 309 | case 3: |
298 | // delete childs too | 310 | // delete childs too |
299 | delete item; | 311 | delete item; |
300 | break; | 312 | break; |
301 | } | 313 | } |
302 | delete groups; | 314 | delete groups; |
303 | 315 | ||
304 | } else if ( ((BTListItem*)item)->type() == "service") { | 316 | } else if ( ((BTListItem*)item)->type() == "service") { |
305 | menu->insertItem( tr("Test1:"), 0); | 317 | menu->insertItem( tr("Test1:"), 0); |
306 | menu->insertItem( tr("connect"), 1); | 318 | menu->insertItem( tr("connect"), 1); |
307 | menu->insertItem( tr("delete"), 2); | 319 | menu->insertItem( tr("delete"), 2); |
308 | 320 | ||
309 | ret = menu->exec( point , 0); | 321 | ret = menu->exec( point , 0); |
310 | 322 | ||
311 | switch(ret) { | 323 | switch(ret) { |
312 | case 0: | 324 | case 0: |
313 | break; | 325 | break; |
314 | case 1: | 326 | case 1: |
315 | break; | 327 | break; |
316 | case 2: | 328 | case 2: |
317 | // delete childs too | 329 | // delete childs too |
318 | delete item; | 330 | delete item; |
319 | break; | 331 | break; |
320 | } | 332 | } |
321 | } | 333 | } |
322 | delete menu; | 334 | delete menu; |
323 | } | 335 | } |
324 | 336 | ||
325 | /** | 337 | /** |
326 | * Search and display avail. services for a device (on expand from device listing) | 338 | * Search and display avail. services for a device (on expand from device listing) |
327 | * | 339 | * |
328 | */ | 340 | */ |
329 | void BlueBase::addServicesToDevice( BTListItem * item ) { | 341 | void BlueBase::addServicesToDevice( BTDeviceItem * item ) { |
330 | qDebug("addServicesToDevice"); | 342 | qDebug("addServicesToDevice"); |
331 | // row of mac adress text(3) | 343 | // row of mac adress text(3) |
332 | RemoteDevice device( item->mac(), item->name() ); | 344 | RemoteDevice device = item->remoteDevice(); |
333 | m_deviceList.insert( item->mac() , item ); | 345 | m_deviceList.insert( item->mac() , item ); |
334 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back | 346 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back |
335 | m_localDevice->searchServices( device ); | 347 | m_localDevice->searchServices( device ); |
336 | } | 348 | } |
337 | 349 | ||
338 | 350 | ||
339 | /** | 351 | /** |
340 | * Overloaded. This one it the one that is connected to the foundServices signal | 352 | * Overloaded. This one it the one that is connected to the foundServices signal |
341 | * @param device the mac address of the remote device | 353 | * @param device the mac address of the remote device |
342 | * @param servicesList the list with the service the device has. | 354 | * @param servicesList the list with the service the device has. |
343 | */ | 355 | */ |
344 | void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { | 356 | void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { |
345 | qDebug("fill services list"); | 357 | qDebug("fill services list"); |
346 | 358 | ||
347 | QMap<QString,BTListItem*>::Iterator it; | 359 | QMap<QString,BTDeviceItem*>::Iterator it; |
348 | BTListItem* deviceItem = 0; | 360 | BTDeviceItem* deviceItem = 0; |
349 | 361 | ||
350 | // get the right devices which requested the search | 362 | // get the right devices which requested the search |
351 | for( it = m_deviceList.begin(); it != m_deviceList.end(); ++it ) { | 363 | it = m_deviceList.find( device ); |
352 | if ( it.key() == device ) { | 364 | if( it == m_deviceList.end() ) |
353 | deviceItem = it.data(); | 365 | return; |
354 | } | 366 | deviceItem = it.data(); |
355 | } | ||
356 | 367 | ||
357 | QValueList<OpieTooth::Services>::Iterator it2; | 368 | QValueList<OpieTooth::Services>::Iterator it2; |
358 | BTListItem * serviceItem; | 369 | BTServiceItem * serviceItem; |
359 | 370 | ||
360 | if (!servicesList.isEmpty() ) { | 371 | if (!servicesList.isEmpty() ) { |
361 | // add services | 372 | // add services |
362 | for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { | 373 | for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { |
363 | serviceItem = new BTListItem( deviceItem , (*it2).serviceName() , "" , "service" ); | 374 | serviceItem = new BTServiceItem( deviceItem , (*it2) ); |
364 | serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( (*it2).classIdList() ) ); | 375 | serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( (*it2).classIdList() ) ); |
365 | } | 376 | } |
366 | } else { | 377 | } else { |
367 | serviceItem = new BTListItem( deviceItem , tr("no services found"), "" , "service" ); | 378 | Services s1; |
379 | s1.setServiceName( tr("no serives found") ); | ||
380 | serviceItem = new BTServiceItem( deviceItem, s1 ); | ||
368 | } | 381 | } |
382 | // now remove them from the list | ||
383 | m_deviceList.remove( it ); | ||
369 | } | 384 | } |
370 | 385 | ||
371 | 386 | ||
372 | /** | 387 | /** |
373 | * Add the existing connections (pairs) to the connections tab. | 388 | * Add the existing connections (pairs) to the connections tab. |
374 | * This one triggers the search | 389 | * This one triggers the search |
375 | */ | 390 | */ |
376 | void BlueBase::addConnectedDevices() { | 391 | void BlueBase::addConnectedDevices() { |
377 | m_localDevice->searchConnections(); | 392 | m_localDevice->searchConnections(); |
378 | } | 393 | } |
379 | 394 | ||
380 | 395 | ||
381 | void BlueBase::addConnectedDevices( Connection::ValueList connectionList ) { | 396 | void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) { |
382 | QValueList<OpieTooth::Connection>::Iterator it; | 397 | QValueList<OpieTooth::ConnectionState>::Iterator it; |
383 | BTListItem * connectionItem; | 398 | BTConnectionItem * connectionItem; |
384 | 399 | ||
385 | if ( !connectionList.isEmpty() ) { | 400 | if ( !connectionList.isEmpty() ) { |
386 | 401 | ||
387 | for (it = connectionList.begin(); it != connectionList.end(); ++it) { | 402 | for (it = connectionList.begin(); it != connectionList.end(); ++it) { |
388 | connectionItem = new BTListItem( ListView4 , (*it).mac() , (*it).mac() , "connection" ); | 403 | connectionItem = new BTConnectionItem( ListView4 , (*it) ); |
389 | } | 404 | } |
390 | } else { | 405 | } else { |
391 | connectionItem = new BTListItem( ListView4 , tr("No connections found"), "", "connection" ); | 406 | ConnectionState con; |
407 | con.setMac( tr("No connections found") ); | ||
408 | connectionItem = new BTConnectionItem( ListView4 , con ); | ||
392 | } | 409 | } |
393 | 410 | ||
394 | // recall connection search after some time | 411 | // recall connection search after some time |
395 | QTimer::singleShot( 20000, this, SLOT( addConnectedDevices() ) ); | 412 | QTimer::singleShot( 20000, this, SLOT( addConnectedDevices() ) ); |
396 | } | 413 | } |
397 | 414 | ||
398 | /** | 415 | /** |
399 | * Find out if a device can currently be reached | 416 | * Find out if a device can currently be reached |
400 | */ | 417 | */ |
401 | void BlueBase::deviceActive( const RemoteDevice &device ) { | 418 | void BlueBase::deviceActive( const RemoteDevice &device ) { |
402 | // search by mac, async, gets a signal back | 419 | // search by mac, async, gets a signal back |
420 | // We should have a BTDeviceItem there or where does it get added to the map -zecke | ||
403 | m_localDevice->isAvailable( device.mac() ); | 421 | m_localDevice->isAvailable( device.mac() ); |
404 | } | 422 | } |
405 | 423 | ||
406 | /** | 424 | /** |
407 | * The signal catcher. Set the avail. status on device. | 425 | * The signal catcher. Set the avail. status on device. |
408 | * @param device - the mac address | 426 | * @param device - the mac address |
409 | * @param connected - if it is avail. or not | 427 | * @param connected - if it is avail. or not |
410 | */ | 428 | */ |
411 | void BlueBase::deviceActive( const QString& device, bool connected ) { | 429 | void BlueBase::deviceActive( const QString& device, bool connected ) { |
412 | qDebug("deviceActive slot"); | 430 | qDebug("deviceActive slot"); |
413 | 431 | ||
414 | QMap<QString,BTListItem*>::Iterator it; | 432 | QMap<QString,BTDeviceItem*>::Iterator it; |
415 | BTListItem* deviceItem = 0; | 433 | |
434 | it = m_deviceList.find( device ); | ||
435 | if( it == m_deviceList.end() ) | ||
436 | return; | ||
437 | |||
438 | BTDeviceItem* deviceItem = it.data(); | ||
416 | 439 | ||
417 | // get the right devices which requested the search | ||
418 | for( it = m_deviceList.begin(); it != m_deviceList.end(); ++it ) { | ||
419 | if ( it.key() == device ) { | ||
420 | deviceItem = it.data(); | ||
421 | } | ||
422 | } | ||
423 | 440 | ||
424 | if ( connected ) { | 441 | if ( connected ) { |
425 | deviceItem->setPixmap( 1, m_onPix ); | 442 | deviceItem->setPixmap( 1, m_onPix ); |
426 | } else { | 443 | } else { |
427 | deviceItem->setPixmap( 1, m_offPix ); | 444 | deviceItem->setPixmap( 1, m_offPix ); |
428 | } | 445 | } |
446 | m_deviceList.remove( it ); | ||
429 | } | 447 | } |
430 | 448 | ||
431 | /** | 449 | /** |
432 | * Open the "scan for devices" dialog | 450 | * Open the "scan for devices" dialog |
433 | */ | 451 | */ |
434 | void BlueBase::startScan() { | 452 | void BlueBase::startScan() { |
435 | ScanDialog *scan = new ScanDialog( this, "ScanDialog", | 453 | ScanDialog *scan = new ScanDialog( this, "ScanDialog", |
436 | true, WDestructiveClose ); | 454 | true, WDestructiveClose ); |
437 | QObject::connect( scan, SIGNAL( selectedDevices( const QValueList<RemoteDevice>& ) ), | 455 | QObject::connect( scan, SIGNAL( selectedDevices( const QValueList<RemoteDevice>& ) ), |
438 | this, SLOT( addSearchedDevices( const QValueList<RemoteDevice>& ) ) ); | 456 | this, SLOT( addSearchedDevices( const QValueList<RemoteDevice>& ) ) ); |
439 | 457 | ||
440 | scan->showMaximized(); | 458 | scan->showMaximized(); |
441 | } | 459 | } |
442 | 460 | ||
443 | 461 | ||
444 | /** | 462 | /** |
445 | * Set the informations about the local device in information Tab | 463 | * Set the informations about the local device in information Tab |
446 | */ | 464 | */ |
447 | void BlueBase::setInfo() { | 465 | void BlueBase::setInfo() { |
448 | StatusLabel->setText( status() ); | 466 | StatusLabel->setText( status() ); |
449 | } | 467 | } |
450 | 468 | ||
451 | /** | 469 | /** |
452 | * Decontructor | 470 | * Decontructor |
453 | */ | 471 | */ |
454 | BlueBase::~BlueBase() { | 472 | BlueBase::~BlueBase() { |
455 | writeSavedDevices(); | 473 | writeSavedDevices(); |
456 | delete m_iconLoader; | 474 | delete m_iconLoader; |
457 | } | 475 | } |
458 | 476 | ||
diff --git a/noncore/net/opietooth/manager/bluebase.h b/noncore/net/opietooth/manager/bluebase.h index 73fac97..a8f4fe4 100644 --- a/noncore/net/opietooth/manager/bluebase.h +++ b/noncore/net/opietooth/manager/bluebase.h | |||
@@ -1,85 +1,88 @@ | |||
1 | 1 | ||
2 | #ifndef BLUEBASE_H | 2 | #ifndef BLUEBASE_H |
3 | #define BLUEBASE_H | 3 | #define BLUEBASE_H |
4 | 4 | ||
5 | #include <qvariant.h> | 5 | #include <qvariant.h> |
6 | #include <qwidget.h> | 6 | #include <qwidget.h> |
7 | #include <qscrollview.h> | 7 | #include <qscrollview.h> |
8 | #include <qsplitter.h> | 8 | #include <qsplitter.h> |
9 | #include <qlist.h> | 9 | #include <qlist.h> |
10 | #include <qpixmap.h> | 10 | #include <qpixmap.h> |
11 | 11 | ||
12 | #include "bluetoothbase.h" | 12 | #include "bluetoothbase.h" |
13 | #include "btlistitem.h" | 13 | |
14 | #include "btserviceitem.h" | ||
15 | #include "btdeviceitem.h" | ||
16 | |||
14 | #include "bticonloader.h" | 17 | #include "bticonloader.h" |
15 | 18 | ||
16 | #include <remotedevice.h> | 19 | #include <remotedevice.h> |
17 | #include <manager.h> | 20 | #include <manager.h> |
18 | 21 | ||
19 | class QVBox; | 22 | class QVBox; |
20 | class QHBoxLayout; | 23 | class QHBoxLayout; |
21 | class QGridLayout; | 24 | class QGridLayout; |
22 | class QFrame; | 25 | class QFrame; |
23 | class QLabel; | 26 | class QLabel; |
24 | class QPushButton; | 27 | class QPushButton; |
25 | class QTabWidget; | 28 | class QTabWidget; |
26 | class QCheckBox; | 29 | class QCheckBox; |
27 | 30 | ||
28 | 31 | ||
29 | namespace OpieTooth { | 32 | namespace OpieTooth { |
30 | 33 | ||
31 | class BlueBase : public BluetoothBase { | 34 | class BlueBase : public BluetoothBase { |
32 | Q_OBJECT | 35 | Q_OBJECT |
33 | 36 | ||
34 | public: | 37 | public: |
35 | BlueBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 38 | BlueBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
36 | ~BlueBase(); | 39 | ~BlueBase(); |
37 | 40 | ||
38 | protected: | 41 | protected: |
39 | 42 | ||
40 | 43 | ||
41 | private slots: | 44 | private slots: |
42 | void startScan(); | 45 | void startScan(); |
43 | 46 | ||
44 | private: | 47 | private: |
45 | void readConfig(); | 48 | void readConfig(); |
46 | void writeConfig(); | 49 | void writeConfig(); |
47 | void readSavedDevices(); | 50 | void readSavedDevices(); |
48 | void writeSavedDevices(); | 51 | void writeSavedDevices(); |
49 | void writeToHciConfig(); | 52 | void writeToHciConfig(); |
50 | QString status()const; | 53 | QString status()const; |
51 | void initGui(); | 54 | void initGui(); |
52 | void setInfo(); | 55 | void setInfo(); |
53 | Manager *m_localDevice; | 56 | Manager *m_localDevice; |
54 | QMap<QString,BTListItem*> m_deviceList; | 57 | QMap<QString,BTDeviceItem*> m_deviceList; |
55 | 58 | ||
56 | void deviceActive( const RemoteDevice &device ); | 59 | void deviceActive( const RemoteDevice &device ); |
57 | 60 | ||
58 | QString m_deviceName; | 61 | QString m_deviceName; |
59 | QString m_defaultPasskey; | 62 | QString m_defaultPasskey; |
60 | bool m_useEncryption; | 63 | bool m_useEncryption; |
61 | bool m_enableAuthentification; | 64 | bool m_enableAuthentification; |
62 | bool m_enablePagescan; | 65 | bool m_enablePagescan; |
63 | bool m_enableInquiryscan; | 66 | bool m_enableInquiryscan; |
64 | 67 | ||
65 | QPixmap m_offPix; | 68 | QPixmap m_offPix; |
66 | QPixmap m_onPix; | 69 | QPixmap m_onPix; |
67 | 70 | ||
68 | BTIconLoader *m_iconLoader; | 71 | BTIconLoader *m_iconLoader; |
69 | 72 | ||
70 | private slots: | 73 | private slots: |
71 | void addSearchedDevices( const QValueList<RemoteDevice> &newDevices ); | 74 | void addSearchedDevices( const QValueList<RemoteDevice> &newDevices ); |
72 | void addServicesToDevice( BTListItem *item ); | 75 | void addServicesToDevice( BTDeviceItem *item ); |
73 | void addServicesToDevice( const QString& device, Services::ValueList ); | 76 | void addServicesToDevice( const QString& device, Services::ValueList ); |
74 | void addConnectedDevices(); | 77 | void addConnectedDevices(); |
75 | void addConnectedDevices( Connection::ValueList ); | 78 | void addConnectedDevices( ConnectionState::ValueList ); |
76 | void startServiceActionClicked( QListViewItem *item ); | 79 | void startServiceActionClicked( QListViewItem *item ); |
77 | void startServiceActionHold( QListViewItem *, const QPoint &, int ); | 80 | void startServiceActionHold( QListViewItem *, const QPoint &, int ); |
78 | void deviceActive( const QString& mac, bool connected ); | 81 | void deviceActive( const QString& mac, bool connected ); |
79 | void applyConfigChanges(); | 82 | void applyConfigChanges(); |
80 | 83 | ||
81 | }; | 84 | }; |
82 | 85 | ||
83 | } | 86 | } |
84 | 87 | ||
85 | #endif | 88 | #endif |
diff --git a/noncore/net/opietooth/manager/btlistitem.cpp b/noncore/net/opietooth/manager/btlistitem.cpp index 82e7c00..36816f8 100644 --- a/noncore/net/opietooth/manager/btlistitem.cpp +++ b/noncore/net/opietooth/manager/btlistitem.cpp | |||
@@ -1,61 +1,11 @@ | |||
1 | 1 | ||
2 | #include "btlistitem.h" | 2 | #include "btlistitem.h" |
3 | 3 | ||
4 | namespace OpieTooth { | 4 | using namespace OpieTooth; |
5 | 5 | ||
6 | 6 | ||
7 | BTListItem::BTListItem( QListView * parent ) : QListViewItem( parent ) { | 7 | BTListItem::BTListItem( QListView * parent ) : QListViewItem( parent ) { |
8 | } | 8 | } |
9 | 9 | ||
10 | BTListItem::BTListItem( QListViewItem * parent ) : QListViewItem( parent ) { | 10 | BTListItem::BTListItem( QListViewItem * parent ) : QListViewItem( parent ) { |
11 | } | 11 | } |
12 | |||
13 | |||
14 | // name, and then mac and then servicetype | ||
15 | BTListItem::BTListItem( QListView * parent, const QString &name , const QString& mac, const QString& type ) | ||
16 | : QListViewItem( parent, name ){ | ||
17 | |||
18 | m_name = name; | ||
19 | m_mac = mac; | ||
20 | m_type = type; | ||
21 | |||
22 | } | ||
23 | |||
24 | BTListItem::BTListItem( QListViewItem * parent , const QString& name, const QString& mac, const QString& type ) | ||
25 | : QListViewItem( parent, name ){ | ||
26 | |||
27 | m_name = name; | ||
28 | m_mac = mac; | ||
29 | m_type = type; | ||
30 | } | ||
31 | |||
32 | |||
33 | void BTListItem::setMac( const QString& mac ) { | ||
34 | m_mac = mac; | ||
35 | } | ||
36 | |||
37 | QString BTListItem::mac() const { | ||
38 | return m_mac; | ||
39 | } | ||
40 | |||
41 | void BTListItem::setName( const QString& name ) { | ||
42 | m_name = name; | ||
43 | } | ||
44 | |||
45 | QString BTListItem::name() const { | ||
46 | return m_name; | ||
47 | } | ||
48 | |||
49 | void BTListItem::setType( const QString& type ) { | ||
50 | m_type = type; | ||
51 | } | ||
52 | |||
53 | QString BTListItem::type() const { | ||
54 | return m_type; | ||
55 | } | ||
56 | |||
57 | |||
58 | BTListItem::~BTListItem() { | ||
59 | } | ||
60 | |||
61 | }; | ||
diff --git a/noncore/net/opietooth/manager/btlistitem.h b/noncore/net/opietooth/manager/btlistitem.h index d7ce03b..6b529d1 100644 --- a/noncore/net/opietooth/manager/btlistitem.h +++ b/noncore/net/opietooth/manager/btlistitem.h | |||
@@ -1,33 +1,18 @@ | |||
1 | #ifndef BTLISTITEM_H | 1 | #ifndef BTLISTITEM_H |
2 | #define BTLISTITEM_H | 2 | #define BTLISTITEM_H |
3 | 3 | ||
4 | #include <qlistview.h> | 4 | #include <qlistview.h> |
5 | 5 | ||
6 | namespace OpieTooth { | 6 | namespace OpieTooth { |
7 | 7 | ||
8 | class BTListItem : public QListViewItem { | 8 | class BTListItem : public QListViewItem { |
9 | |||
10 | public: | 9 | public: |
10 | enum Types { Device =0, Service, Connection }; | ||
11 | BTListItem( QListView * parent ); | 11 | BTListItem( QListView * parent ); |
12 | BTListItem( QListViewItem * parent ); | 12 | BTListItem( QListViewItem * parent ); |
13 | 13 | virtual QString type() const = 0; | |
14 | // name, and then mac and then servicetype | 14 | virtual int typeId() const = 0; |
15 | BTListItem( QListView * , const QString&, const QString&, const QString& ); | ||
16 | BTListItem( QListViewItem * parent , const QString&, const QString& , const QString& ); | ||
17 | ~BTListItem(); | ||
18 | |||
19 | void setMac( const QString& ); | ||
20 | QString mac()const; | ||
21 | void setName( const QString& ); | ||
22 | QString name()const; | ||
23 | void setType( const QString& ); | ||
24 | QString type()const; | ||
25 | private: | ||
26 | QString m_name; | ||
27 | QString m_mac; | ||
28 | QString m_type; | ||
29 | |||
30 | }; | 15 | }; |
31 | }; | 16 | }; |
32 | 17 | ||
33 | #endif | 18 | #endif |
diff --git a/noncore/net/opietooth/manager/manager.pro b/noncore/net/opietooth/manager/manager.pro index 4f0ea60..d36b8df2 100644 --- a/noncore/net/opietooth/manager/manager.pro +++ b/noncore/net/opietooth/manager/manager.pro | |||
@@ -1,27 +1,27 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | CONFIG = qt warn_on debug | 2 | CONFIG = qt warn_on debug |
3 | #CONFIG = qt warn_on release | 3 | #CONFIG = qt warn_on release |
4 | HEADERS = popuphelper.h bluebase.h scandialog.h btlistitem.h hciconfwrapper.h bticonloader.h | 4 | HEADERS = btconnectionitem.h btdeviceitem.h btserviceitem.h stdpopups.h popuphelper.h bluebase.h scandialog.h btlistitem.h hciconfwrapper.h bticonloader.h |
5 | SOURCES = popuphelper.cpp main.cpp bluebase.cpp scandialog.cpp btlistitem.cpp hciconfwrapper.cpp bticonloader.cpp | 5 | SOURCES = btconnectionitem.cpp btdeviceitem.cpp btserviceitem.h stdpopups.cpp popuphelper.cpp main.cpp bluebase.cpp scandialog.cpp btlistitem.cpp hciconfwrapper.cpp bticonloader.cpp |
6 | INCLUDEPATH += $(OPIEDIR)/include | 6 | INCLUDEPATH += $(OPIEDIR)/include |
7 | INCLUDEPATH += $(OPIEDIR)/noncore/net/opietooth/lib | 7 | INCLUDEPATH += $(OPIEDIR)/noncore/net/opietooth/lib |
8 | DEPENDPATH += $(OPIEDIR)/include | 8 | DEPENDPATH += $(OPIEDIR)/include |
9 | LIBS += -lqpe -lopietooth -lopie | 9 | LIBS += -lqpe -lopietooth -lopie |
10 | INTERFACES = bluetoothbase.ui devicedialog.ui | 10 | INTERFACES = bluetoothbase.ui devicedialog.ui |
11 | DESTDIR = $(OPIEDIR)/bin | 11 | DESTDIR = $(OPIEDIR)/bin |
12 | TARGET = bluetooth-manager | 12 | TARGET = bluetooth-manager |
13 | 13 | ||
14 | TRANSLATIONS = ../../../../i18n/de/bluetooth-manager.ts \ | 14 | TRANSLATIONS = ../../../../i18n/de/bluetooth-manager.ts \ |
15 | ../../../../i18n/en/bluetooth-manager.ts \ | 15 | ../../../../i18n/en/bluetooth-manager.ts \ |
16 | ../../../../i18n/es/bluetooth-manager.ts \ | 16 | ../../../../i18n/es/bluetooth-manager.ts \ |
17 | ../../../../i18n/fr/bluetooth-manager.ts \ | 17 | ../../../../i18n/fr/bluetooth-manager.ts \ |
18 | ../../../../i18n/hu/bluetooth-manager.ts \ | 18 | ../../../../i18n/hu/bluetooth-manager.ts \ |
19 | ../../../../i18n/ja/bluetooth-manager.ts \ | 19 | ../../../../i18n/ja/bluetooth-manager.ts \ |
20 | ../../../../i18n/ko/bluetooth-manager.ts \ | 20 | ../../../../i18n/ko/bluetooth-manager.ts \ |
21 | ../../../../i18n/no/bluetooth-manager.ts \ | 21 | ../../../../i18n/no/bluetooth-manager.ts \ |
22 | ../../../../i18n/pl/bluetooth-manager.ts \ | 22 | ../../../../i18n/pl/bluetooth-manager.ts \ |
23 | ../../../../i18n/pt/bluetooth-manager.ts \ | 23 | ../../../../i18n/pt/bluetooth-manager.ts \ |
24 | ../../../../i18n/pt_BR/bluetooth-manager.ts \ | 24 | ../../../../i18n/pt_BR/bluetooth-manager.ts \ |
25 | ../../../../i18n/sl/bluetooth-manager.ts \ | 25 | ../../../../i18n/sl/bluetooth-manager.ts \ |
26 | ../../../../i18n/zh_CN/bluetooth-manager.ts \ | 26 | ../../../../i18n/zh_CN/bluetooth-manager.ts \ |
27 | ../../../../i18n/zh_TW/bluetooth-manager.ts | 27 | ../../../../i18n/zh_TW/bluetooth-manager.ts |
diff --git a/noncore/net/opietooth/manager/popuphelper.cpp b/noncore/net/opietooth/manager/popuphelper.cpp index 2a6dad0..d8404d6 100644 --- a/noncore/net/opietooth/manager/popuphelper.cpp +++ b/noncore/net/opietooth/manager/popuphelper.cpp | |||
@@ -1,25 +1,28 @@ | |||
1 | 1 | ||
2 | #include "stdpopups.h" | ||
3 | |||
2 | #include "popuphelper.h" | 4 | #include "popuphelper.h" |
3 | 5 | ||
4 | using namespace OpieTooth; | 6 | using namespace OpieTooth; |
5 | 7 | ||
6 | PopupHelper::PopupHelper() { | 8 | PopupHelper::PopupHelper() { |
7 | init(); | 9 | init(); |
8 | } | 10 | } |
9 | PopupHelper::~PopupHelper() { | 11 | PopupHelper::~PopupHelper() { |
10 | 12 | ||
11 | } | 13 | } |
12 | void PopupHelper::insert( int id, popupFactory fact ) { | 14 | void PopupHelper::insert( int id, popupFactory fact ) { |
13 | m_map.insert(id, fact ); | 15 | m_map.insert(id, fact ); |
14 | } | 16 | } |
15 | QPopupMenu* PopupHelper::find( int id ) { | 17 | QPopupMenu* PopupHelper::find( int id, const Services& ser, QListViewItem* item ) { |
16 | FactoryMap::Iterator it = m_map.find(id ); | 18 | FactoryMap::Iterator it = m_map.find(id ); |
17 | if ( it != m_map.end() ) { | 19 | if ( it != m_map.end() ) { |
18 | popupFactory fact = it.data(); | 20 | popupFactory fact = it.data(); |
19 | return (*fact)(); | 21 | return (*fact)(ser, item); |
20 | } | 22 | } |
21 | return 0l; | 23 | return 0l; |
22 | } | 24 | } |
23 | void PopupHelper::init() { | 25 | void PopupHelper::init() { |
24 | 26 | insert( 1, newRfcComPopup ); | |
27 | insert(2, newObexPushPopup ); | ||
25 | } | 28 | } |
diff --git a/noncore/net/opietooth/manager/popuphelper.h b/noncore/net/opietooth/manager/popuphelper.h index 7485f71..7541ac5 100644 --- a/noncore/net/opietooth/manager/popuphelper.h +++ b/noncore/net/opietooth/manager/popuphelper.h | |||
@@ -1,25 +1,27 @@ | |||
1 | 1 | ||
2 | #ifndef OPIE_TOOTH_POPUP_HELPER | 2 | #ifndef OPIE_TOOTH_POPUP_HELPER |
3 | #define OPIE_TOOTH_POPUP_HELPER | 3 | #define OPIE_TOOTH_POPUP_HELPER |
4 | 4 | ||
5 | #include <qlistview.h> | ||
5 | #include <qpopupmenu.h> | 6 | #include <qpopupmenu.h> |
6 | #include <qmap.h> | 7 | #include <qmap.h> |
7 | 8 | ||
9 | #include <services.h> | ||
8 | 10 | ||
9 | namespace OpieTooth { | 11 | namespace OpieTooth { |
10 | typedef QPopupMenu* (*popupFactory)(void); | 12 | typedef QPopupMenu* (*popupFactory)(const Services&, QListViewItem*); |
11 | typedef QMap<int, popupFactory> FactoryMap; | 13 | typedef QMap<int, popupFactory> FactoryMap; |
12 | class PopupHelper { | 14 | class PopupHelper { |
13 | public: | 15 | public: |
14 | PopupHelper(); | 16 | PopupHelper(); |
15 | ~PopupHelper(); | 17 | ~PopupHelper(); |
16 | void insert( int id, popupFactory fact ); | 18 | void insert( int id, popupFactory fact ); |
17 | QPopupMenu* find( int id ); | 19 | QPopupMenu* find( int id, const Services&, QListViewItem* ); |
18 | private: | 20 | private: |
19 | void init(); | 21 | void init(); |
20 | FactoryMap m_map; | 22 | FactoryMap m_map; |
21 | 23 | ||
22 | }; | 24 | }; |
23 | }; | 25 | }; |
24 | 26 | ||
25 | #endif | 27 | #endif |