summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/opietooth2/OTDriver.h
Unidiff
Diffstat (limited to 'noncore/settings/networksettings2/opietooth2/OTDriver.h') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTDriver.h232
1 files changed, 232 insertions, 0 deletions
diff --git a/noncore/settings/networksettings2/opietooth2/OTDriver.h b/noncore/settings/networksettings2/opietooth2/OTDriver.h
new file mode 100644
index 0000000..b54ffdf
--- a/dev/null
+++ b/noncore/settings/networksettings2/opietooth2/OTDriver.h
@@ -0,0 +1,232 @@
1/***************************************************************************
2 * Copyright (C) 2003 by Mattia Merzi *
3 * ottobit@ferrara.linux.it *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 ***************************************************************************/
10
11#ifndef OTDRIVER_H
12#define OTDRIVER_H
13
14/*
15 * This class handles the connection with the BlueZ libraries, implements
16 * most of the bluetooth-related functions and owns the KBTDevice class
17 * that is a single local bluetooth device representation.
18 * It is used as a Singleton pattern thru the getDefaultConnector() method.
19 *
20 */
21#include <qobject.h>
22#include <opie2/odebug.h>
23#include <bluezlib.h>
24
25#include <OTDeviceAddress.h>
26
27namespace Opietooth2 {
28
29class OTGateway;
30class OTHCISocket;
31class OTDeviceAddress;
32class OTPeer;
33
34/*
35 * This is the representation of a
36 * Bluetooth device for the local
37 * machine.
38 */
39class OTDriver : public QObject {
40
41 Q_OBJECT
42
43public:
44
45 OTDriver( OTGateway * Ot, struct hci_dev_info* di);
46 ~OTDriver();
47
48 inline OTGateway * gateway() const
49 { return OT; }
50
51 /*
52 * Initializes the device using the passed hci_dev_info
53 * struct, contining the basic information in order to
54 * talk with the pyisical device.
55 */
56 void init(struct hci_dev_info* di);
57
58 /*
59 * Open the device and obtains a file descriptor to id
60 * return if open
61 */
62 bool open();
63
64 OTHCISocket * openSocket();
65
66 void closeSocket();
67
68 /*
69 * Return true if the device is opened.
70 */
71 int isOpen()
72 { return Fd != -1; };
73
74 /*
75 * Calls the ioctl(HCIDEVRESET) in order to
76 * reset the device.
77 */
78 int reset();
79
80 // set Up if true and not yet up
81 void setUp( bool Mode );
82
83 /*
84 * Turn the device up and the reinitializes the device.
85 * If the device is already up, nothing is done.
86 */
87 void bringUp();
88
89 /*
90 * Turn the device down and the reinitializes the device.
91 * If the device is already down, nothing is done.
92 */
93 void bringDown();
94
95 // is the device UP now
96 bool isUp() const
97 { return IsUp; }
98
99 // get current state
100 // return 1 if UP, 0 if DOWN, -1 if ERROR
101 int currentState();
102
103 /*
104 * Returns the name of the device. If the device is
105 * down, the device id is returned.
106 */
107 QString name();
108
109 int devId() const
110 { return Dev_id; };
111
112 /*
113 * Returns the string representation of the device id,
114 * with the same format of the hciconfig tool.
115 */
116 QString devname()
117 { return Dev; };
118
119 /*
120 * Returns the file descriptor for the local
121 * connection to this device
122 */
123 int fd() const
124 { return Fd; };
125 void setfd(int _fd)
126 { Fd = _fd; };
127
128 void setType(int _type)
129 { Type = _type; };
130 int type() const
131 { return Type; };
132 QString strType();
133
134 int iscan() const
135 { return Iscan; }
136 void setIScan(int _iscan)
137 { Iscan = _iscan; }
138
139 int pscan() const
140 { return Pscan; }
141 void setPScan(int _pscan)
142 { Pscan = _pscan; }
143
144 int authentication() const
145 { return Auth; }
146 void setAuthentication(int _auth)
147 { Auth = _auth; }
148
149 int encryption() const
150 { return Encrypt; }
151 void setEncryption(int _encrypt)
152 { Encrypt = _encrypt; }
153
154 void setDevId(int _dev_id)
155 { Dev_id = _dev_id; };
156 void setDev(char* _dev)
157 { Dev = _dev; };
158
159 void setFlags( unsigned long flags);
160
161 const OTDeviceAddress & address()
162 { return Address; }
163
164 void setFeatures( unsigned char * _f);
165 QString features()
166 { return Features; }
167
168 void setManufacturer(int compid);
169 QString manufacturer()
170 { return Manufacturer; }
171
172 QString revision();
173
174 void setScanMode(bool iscan, bool pscan);
175 void setClass(unsigned long cls);
176
177 void changeDevName(const char* name);
178 void changeEncryption(bool _encryption);
179 void changeAuthentication(bool _auth);
180
181 void getClass( QString & service,
182 QString & device );
183 void changeClass( unsigned char service,
184 unsigned char major,
185 unsigned char minor);
186
187 QString getPeerName( const OTDeviceAddress & PAddr );
188
189 // address must be connected to this driver
190 long getLinkQuality( const OTDeviceAddress & Address );
191
192signals :
193
194 void error( const QString & );
195 void stateChange( OTDriver * , bool );
196 void driverDisappeared( OTDriver * );
197
198private slots :
199
200 /*
201 * Reinitializes the device, obtaining a fresh
202 * hci_dev_info structure.
203 */
204 void reinit();
205 void SLOT_CloseFd();
206
207private:
208
209 QString getRevEricsson();
210 QString getRevCsr(unsigned short rev);
211
212 QString Name;
213 QString Dev;
214 QString Revision;
215 QString Manufacturer;
216 OTDeviceAddress Address;
217 QString Features;
218 QTimer * AutoClose;
219
220 int Dev_id,Fd,Type;
221 bool IsUp;
222 int Iscan,Pscan,Auth,Encrypt;
223
224 // socket bound to this device
225 OTHCISocket * Socket;
226
227 // backpointer to opietooth system
228 OTGateway * OT;
229};
230
231}
232#endif