summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/opietooth2/OTHCISocket.h
Unidiff
Diffstat (limited to 'noncore/settings/networksettings2/opietooth2/OTHCISocket.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTHCISocket.h116
1 files changed, 116 insertions, 0 deletions
diff --git a/noncore/settings/networksettings2/opietooth2/OTHCISocket.h b/noncore/settings/networksettings2/opietooth2/OTHCISocket.h
new file mode 100644
index 0000000..d508078
--- a/dev/null
+++ b/noncore/settings/networksettings2/opietooth2/OTHCISocket.h
@@ -0,0 +1,116 @@
1//-*-c++-*-
2/***************************************************************************
3 * Copyright (C) 2003 by Fred Schaettgen *
4 * kdebluetooth@schaettgen.de *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 ***************************************************************************/
11
12#ifndef OTHCISOCKET_H
13#define OTHCISOCKET_H
14
15#include <qobject.h>
16#include <qsocketnotifier.h>
17#include <qsocketdevice.h>
18#include <qguardedptr.h>
19
20class QSocket;
21
22namespace Opietooth2 {
23
24/** Bluetooth HCI Socket class.
25 * This class provides socket level access to the Bluez HCI layer.
26 * It is set up to filter out all but HCI event packets, since more
27 * is only allowed for privileged users.
28 * @todo writeHciEvent() function
29 * @todo error handling
30 */
31
32class OTDriver;
33
34class OTHCISocket : public QObject {
35
36 Q_OBJECT
37
38public:
39
40 OTHCISocket( OTDriver * ConnectTo );
41 virtual ~OTHCISocket();
42
43 /** Opens a HCI socket for the given
44 @return true if sucessfully opened, false otherwise
45 */
46 virtual bool open();
47
48 /** Closes the HCI socket. */
49 virtual void close();
50
51 bool sendCommand( unsigned char ogf,
52 unsigned short ocf,
53 QByteArray buf
54 );
55 bool readStatus( unsigned char ogf,
56 unsigned short ocf,
57 int *status,
58 int timeout_ms = 1000);
59
60 /** Reads whole HCI packet.
61 @param packetType [out] The packet type. Should always be ...
62 @param eventCode [out] The event code.
63 @param buflen [in/out] The maximum size of the buffer / the number of
64 bytes written into the buffer.
65 @param paramBuf pointer to a buffer for the HCI event packet
66 @return true if successful
67 */
68 /*bool readEvent(unsigned char &packetType,
69 unsigned char &eventCode, unsigned char &buflen,
70 char* paramBuf);*/
71
72 enum Error { ErrSocket = 1 };
73
74 /** Forces reading the next event packet. */
75 void readEvent( void );
76
77 /** Returns the internal socket */
78 int socket( void );
79
80 inline QSocketDevice & socketDevice()
81 { return HCISocket; }
82
83 inline OTDriver * driver() const
84 { return Driver; }
85
86signals:
87
88 void event( unsigned char eventCode, QByteArray buf);
89 void error( QString message );
90 void connectionClosed( );
91
92private:
93
94 void updateStatus( const QByteArray& data );
95
96 //QSocketDevice hciSocket;
97 QGuardedPtr<QSocketNotifier> HCIReadNotifier;
98 QSocketDevice HCISocket;
99 OTDriver * Driver ;
100
101 bool BStatusSet;
102 unsigned short LastStatusOcf;
103 unsigned char LastStatusOgf;
104 int LastStatus;
105
106private slots:
107
108 void slotSocketActivated();
109 void slotSocketError(int);
110 void slotConnectionClosed();
111
112};
113
114};
115
116#endif