Diffstat (limited to 'noncore/settings/networksettings2/opietooth2/OTPeer.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/opietooth2/OTPeer.h | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/noncore/settings/networksettings2/opietooth2/OTPeer.h b/noncore/settings/networksettings2/opietooth2/OTPeer.h new file mode 100644 index 0000000..c09af15 --- a/dev/null +++ b/noncore/settings/networksettings2/opietooth2/OTPeer.h | |||
@@ -0,0 +1,135 @@ | |||
1 | //-*-c++-*- | ||
2 | /*************************************************************************** | ||
3 | * Copyright (C) 2003 by Fred Schaettgen * | ||
4 | * kdebluetooth@0xF.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 OTPEER_H | ||
13 | #define OTPEER_H | ||
14 | |||
15 | #include <qstring.h> | ||
16 | #include <qobject.h> | ||
17 | #include <qvector.h> | ||
18 | #include <bluezlib.h> | ||
19 | #include <OTDeviceAddress.h> | ||
20 | |||
21 | class QTextStream; | ||
22 | class QTimerEvent; | ||
23 | |||
24 | namespace Opietooth2 { | ||
25 | |||
26 | class OTGateway; | ||
27 | |||
28 | class OTDriver; | ||
29 | class OTSDPService; | ||
30 | class OTSDPAttribute; | ||
31 | class OTUUID; | ||
32 | typedef QVector<OTSDPService> ServiceVector; | ||
33 | |||
34 | class OTPeer : public QObject { | ||
35 | |||
36 | Q_OBJECT; | ||
37 | |||
38 | public : | ||
39 | |||
40 | typedef enum PeerState_E { | ||
41 | Peer_Unknown = -1, | ||
42 | Peer_Down = 0, | ||
43 | Peer_Up = 1 | ||
44 | } PeerState_t; | ||
45 | |||
46 | OTPeer( OTGateway * _OT ); | ||
47 | OTPeer( QTextStream & TS, OTGateway * _TS ); | ||
48 | ~OTPeer(); | ||
49 | |||
50 | inline OTGateway * gateway() const | ||
51 | { return OT; } | ||
52 | |||
53 | inline int deviceClass( void ) const | ||
54 | { return Class; } | ||
55 | inline void setDeviceClass( int cls ) | ||
56 | { Class = cls; } | ||
57 | |||
58 | void setAddress( const OTDeviceAddress & A ) | ||
59 | { Addr = A; } | ||
60 | |||
61 | const OTDeviceAddress & address( void ) | ||
62 | { return Addr; } | ||
63 | |||
64 | inline QString name( void ) const | ||
65 | { return Name; } | ||
66 | inline void setName( const QString & n ) | ||
67 | { Name = n; } | ||
68 | |||
69 | ServiceVector & services( bool Force = 0 ) | ||
70 | { if( Force || serviceList.count() == 0 ) { | ||
71 | updateServices(); | ||
72 | } | ||
73 | return serviceList; | ||
74 | } | ||
75 | |||
76 | /* Returns TRUE if the device has at least a service | ||
77 | with inside the required class Id.*/ | ||
78 | bool hasServiceClassID( const OTUUID & uuid); | ||
79 | |||
80 | /* Get a vector of Rfcomm channels of the services | ||
81 | having "uuid" in the class ID List */ | ||
82 | QArray<int> rfcommList( const OTUUID & uuid ); | ||
83 | |||
84 | inline void setState( PeerState_t S) | ||
85 | { State = S; } | ||
86 | inline PeerState_t state( void ) | ||
87 | { return State; } | ||
88 | |||
89 | // go and find out state | ||
90 | // will report back with signal | ||
91 | void findOutState( int timeoutInSec = 1, bool Force = 0 ); | ||
92 | void stopFindingOutState( void ); | ||
93 | |||
94 | // return driver to which this peer is connected to | ||
95 | // if it is connected | ||
96 | inline OTDriver * connectedTo( void ) const | ||
97 | { return ConnectedTo; } | ||
98 | inline void setConnectedTo( OTDriver * D ) | ||
99 | { ConnectedTo = D; } | ||
100 | |||
101 | void save( QTextStream& TS ); | ||
102 | void load( QTextStream& TS ); | ||
103 | |||
104 | signals : | ||
105 | |||
106 | // report back state | ||
107 | void peerStateReport( OTPeer *); | ||
108 | void error( const QString & ); | ||
109 | |||
110 | protected : | ||
111 | |||
112 | // while polling for result of ping | ||
113 | void timerEvent( QTimerEvent * ev ); | ||
114 | |||
115 | private: | ||
116 | |||
117 | void updateServices(); | ||
118 | |||
119 | OTGateway * OT; | ||
120 | OTDeviceAddress Addr; | ||
121 | QString Name; | ||
122 | int Class; | ||
123 | ServiceVector serviceList; | ||
124 | // -1 : don't know, 0 no, 1 yes | ||
125 | PeerState_t State; | ||
126 | OTDriver * ConnectedTo; | ||
127 | |||
128 | int ProbeFD; | ||
129 | int ProbePhase; // see OTDriver | ||
130 | long ProbeTimeout; | ||
131 | }; | ||
132 | |||
133 | } | ||
134 | |||
135 | #endif | ||