29
|
1 |
/*
|
31
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
29
|
8 |
*
|
31
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
29
|
11 |
*
|
31
|
12 |
* Contributors:
|
29
|
13 |
*
|
31
|
14 |
* Description: Bluetooth connection tracker and manager.
|
|
15 |
*
|
29
|
16 |
*/
|
|
17 |
|
|
18 |
#ifndef BTNOTIFCONNECTIONTRACKER_H
|
|
19 |
#define BTNOTIFCONNECTIONTRACKER_H
|
|
20 |
|
|
21 |
|
|
22 |
#include <e32property.h>
|
|
23 |
#include <btmanclient.h>
|
|
24 |
#include <bluetooth/pairing.h>
|
|
25 |
#include "btnotifserver.h"
|
|
26 |
|
|
27 |
class CBTNotificationManager;
|
|
28 |
class CbtnotifConnectionTrackerTest;
|
31
|
29 |
class CBTNotifPairingManager;
|
29
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
/**
|
|
34 |
* CBTNotifConnectionTracker keeps track of remote device connections
|
|
35 |
*
|
|
36 |
* @since Symbian^4
|
|
37 |
*/
|
31
|
38 |
NONSHARABLE_CLASS( CBTNotifConnectionTracker ) : public CBase
|
29
|
39 |
{
|
|
40 |
|
|
41 |
public:
|
|
42 |
|
|
43 |
/**
|
|
44 |
* Two-phased constructor.
|
|
45 |
* @param aServer Pointer to our parent
|
|
46 |
*/
|
|
47 |
static CBTNotifConnectionTracker* NewL( CBTNotifServer* aServer );
|
|
48 |
|
|
49 |
/**
|
|
50 |
* Destructor.
|
|
51 |
*/
|
|
52 |
virtual ~CBTNotifConnectionTracker();
|
|
53 |
|
|
54 |
/**
|
|
55 |
* Get a pointer to the btnotif server object.
|
|
56 |
*
|
|
57 |
* @since Symbian^4
|
|
58 |
* @return The server.
|
|
59 |
*/
|
|
60 |
inline CBTNotifServer* Server() const
|
|
61 |
{ return iServer; }
|
|
62 |
|
|
63 |
/**
|
|
64 |
* Get a pointer to the notification manager.
|
|
65 |
* This handle can be used for queueing notifications.
|
|
66 |
*
|
|
67 |
* @since Symbian^4
|
|
68 |
* @return The notification manager.
|
|
69 |
*/
|
|
70 |
inline CBTNotificationManager* NotificationManager() const
|
|
71 |
{ return iServer->NotificationManager(); }
|
|
72 |
|
|
73 |
/**
|
|
74 |
* Get the shared handle to BT registry server.
|
|
75 |
* This handle can be used for creating subsessions.
|
|
76 |
*
|
|
77 |
* @since Symbian^4
|
|
78 |
* @return Session with BT registry server.
|
|
79 |
*/
|
|
80 |
inline RBTRegServ& RegistryServerSession()
|
|
81 |
{ return iBTRegistrySession; }
|
|
82 |
|
|
83 |
/**
|
|
84 |
* Get the handle to the socket server.
|
|
85 |
* This handle can be used for creating subsessions.
|
|
86 |
*
|
|
87 |
* @since Symbian^4
|
|
88 |
* @return Session with the socket server.
|
|
89 |
*/
|
|
90 |
inline RSocketServ& SocketServerSession()
|
|
91 |
{ return iSockServ; }
|
31
|
92 |
|
29
|
93 |
/**
|
31
|
94 |
* Processes a message for notifiers related to pairings.
|
|
95 |
* ( These are usually issued by BT stack. However, any application
|
|
96 |
* is not restricted to do so (e.g., for testing purpose).
|
29
|
97 |
*
|
|
98 |
* @since Symbian^4
|
|
99 |
* @param aMessage The message containing the details of the client request.
|
|
100 |
*/
|
31
|
101 |
void HandlePairingNotifierRequestL( const RMessage2& aMessage );
|
|
102 |
|
29
|
103 |
/**
|
|
104 |
* Handle a request related to pairing.
|
|
105 |
*
|
|
106 |
* @since Symbian^4
|
31
|
107 |
* @param aMessage The message containing the details of the client request.
|
29
|
108 |
*/
|
|
109 |
void HandleBondingRequestL( const RMessage2& aMessage );
|
|
110 |
|
|
111 |
/**
|
|
112 |
* Check repeated connection attempts, and record rejected/accepted queries.
|
|
113 |
*
|
|
114 |
* @since Symbian^4
|
|
115 |
* @param aDevice The details of the remote device for this query.
|
|
116 |
* @param aAccepted ETrue if the user accepted the request, EFalse if rejected.
|
|
117 |
* @return ETrue if the user should be queried for blocking this device,
|
|
118 |
* EFalse if no query should be launched by the caller.
|
|
119 |
*/
|
|
120 |
TBool UpdateBlockingHistoryL( const CBTDevice* aDevice, TBool aAccepted );
|
|
121 |
|
|
122 |
private:
|
|
123 |
|
|
124 |
CBTNotifConnectionTracker( CBTNotifServer* aServer );
|
|
125 |
|
|
126 |
void ConstructL();
|
|
127 |
|
|
128 |
/**
|
|
129 |
* Record and check the time between connection attempts.
|
|
130 |
*
|
|
131 |
* @since Symbian^4
|
|
132 |
* @param aAccepted ETrue if the user accepted the request, EFalse if rejected.
|
|
133 |
* @return EFalse if the attempt followed the previous attempt too fast,
|
|
134 |
* otherwise ETrue.
|
|
135 |
*/
|
|
136 |
TBool RecordConnectionAttempts( TBool aAccepted );
|
|
137 |
|
|
138 |
private: // data
|
|
139 |
|
|
140 |
/**
|
|
141 |
* Time of the last denied connection attempt.
|
|
142 |
*/
|
|
143 |
TInt64 iLastReject;
|
|
144 |
|
|
145 |
/**
|
|
146 |
* Array of device addresses that the user has denied access.
|
|
147 |
*/
|
|
148 |
RArray<TBTDevAddr> iDeniedRequests;
|
|
149 |
|
|
150 |
/**
|
|
151 |
* Single session with BTRegistry, to be used for subsessions.
|
|
152 |
*/
|
|
153 |
RBTRegServ iBTRegistrySession;
|
|
154 |
|
|
155 |
/**
|
|
156 |
* Single session with the socket server, to be used for subsessions.
|
|
157 |
*/
|
|
158 |
RSocketServ iSockServ;
|
|
159 |
|
|
160 |
/**
|
|
161 |
* Reference to our parent the server class.
|
|
162 |
* Not own.
|
|
163 |
*/
|
|
164 |
CBTNotifServer* iServer;
|
31
|
165 |
|
|
166 |
/**
|
|
167 |
* Object for managing the application pairing.
|
|
168 |
* Own.
|
|
169 |
*/
|
|
170 |
CBTNotifPairingManager* iPairingManager;
|
29
|
171 |
|
|
172 |
BTUNITTESTHOOK
|
|
173 |
|
|
174 |
};
|
|
175 |
|
|
176 |
#endif // BTNOTIFCONNECTIONTRACKER_H
|