1 /* |
|
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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef BTNOTIFINCOMINGPAIRINGHANDLER_H |
|
20 #define BTNOTIFINCOMINGPAIRINGHANDLER_H |
|
21 |
|
22 #include <bt_sock.h> |
|
23 #include "btnotifBasePairingHandler.h" |
|
24 |
|
25 /** |
|
26 * Class CBTNotifIncomingPairingHandler |
|
27 * |
|
28 * Handles an incoming pairing. |
|
29 * |
|
30 * @since Symbian^4 |
|
31 */ |
|
32 NONSHARABLE_CLASS( CBTNotifIncomingPairingHandler ) : public CBTNotifBasePairingHandler |
|
33 { |
|
34 public: |
|
35 |
|
36 /** |
|
37 * Two-phase constructor |
|
38 * @param aParent the owner of this observer |
|
39 * @param aAddr the remote device this observer is targeted to |
|
40 */ |
|
41 static CBTNotifBasePairingHandler* NewL( CBTNotifSecurityManager& aParent, |
|
42 const TBTDevAddr& aAddr); |
|
43 |
|
44 /** |
|
45 * Destructor |
|
46 */ |
|
47 ~CBTNotifIncomingPairingHandler(); |
|
48 |
|
49 |
|
50 private: // From CBTNotifBasePairingHandler |
|
51 |
|
52 /** |
|
53 * Start observing the result of pairing which was originated from |
|
54 * the remote device. |
|
55 * @param the address of the remote device to be paired |
|
56 * @return KErrNone if this request is accepted; otherwise an error code |
|
57 */ |
|
58 TInt ObserveIncomingPair( const TBTDevAddr& aAddr ); |
|
59 |
|
60 /** |
|
61 * Start an outgoing pairing with the remote device. |
|
62 * @param the address of the remote device to be paired |
|
63 * @return KErrNone if this request is accepted; otherwise an error code |
|
64 */ |
|
65 void HandleOutgoingPairL( const TBTDevAddr& aAddr, TUint aCod ); |
|
66 |
|
67 /** |
|
68 * Cancels pairing handling with the specified device |
|
69 * @param aAddr the address of the device the pairing is with |
|
70 */ |
|
71 void StopPairHandling( const TBTDevAddr& aAddr ); |
|
72 |
|
73 /** |
|
74 * Handle a pairing result with the remote device which this is for. |
|
75 * Must be specialized by subclass. |
|
76 * |
|
77 * @param aResult The status code of the pairing or authentication result. |
|
78 */ |
|
79 void DoHandlePairServerResult( TInt aResult ); |
|
80 |
|
81 /** |
|
82 * Handles event of registry new paired event with the remote |
|
83 * device this is for. |
|
84 * @aType the type of authentication with the device. |
|
85 */ |
|
86 void DoHandleRegistryNewPairedEvent( const TBTNamelessDevice& aDev ); |
|
87 |
|
88 private: // from base class MBtSimpleActiveObserver |
|
89 |
|
90 /** |
|
91 * Callback to notify that an outstanding request has completed. |
|
92 * |
|
93 * @since Symbian^4 |
|
94 * @param aActive Pointer to the active object that completed. |
|
95 * @param aId The ID that identifies the outstanding request. |
|
96 * @param aStatus The status of the completed request. |
|
97 */ |
|
98 virtual void RequestCompletedL( CBtSimpleActive* aActive, TInt aStatus ); |
|
99 |
|
100 /** |
|
101 * Callback from Docancel() for handling cancelation of an outstanding request. |
|
102 * |
|
103 * @since Symbian^4 |
|
104 * @param aId The ID that identifies the outstanding request. |
|
105 */ |
|
106 virtual void CancelRequest( TInt aRequestId ); |
|
107 |
|
108 /** |
|
109 * Callback to notify that an error has occurred in RunL. |
|
110 * |
|
111 * @since Symbian^4 |
|
112 * @param aActive Pointer to the active object that completed. |
|
113 * @param aId The ID that identifies the outstanding request. |
|
114 * @param aStatus The status of the completed request. |
|
115 */ |
|
116 virtual void HandleError( CBtSimpleActive* aActive, TInt aError ); |
|
117 |
|
118 private: |
|
119 |
|
120 /** |
|
121 * C++ default constructor |
|
122 */ |
|
123 CBTNotifIncomingPairingHandler(CBTNotifSecurityManager& aParent, const TBTDevAddr& aAddr); |
|
124 |
|
125 /** |
|
126 * 2nd phase constructor. |
|
127 */ |
|
128 void ConstructL(); |
|
129 |
|
130 /** |
|
131 * Start monitoring physical link events if it hasn't yet. |
|
132 * |
|
133 * @since Symbian^4 |
|
134 * |
|
135 */ |
|
136 void MonitorPhysicalLink(); |
|
137 |
|
138 /** |
|
139 * Opens physical link adaptor with the device. |
|
140 * |
|
141 * @since Symbian^4 |
|
142 * @return KErrNone if the physical link exists. |
|
143 * |
|
144 */ |
|
145 TInt OpenPhysicalLinkAdaptor(); |
|
146 |
|
147 /** |
|
148 * Cancel all outstanding requests. |
|
149 * |
|
150 * @since Symbian^4 |
|
151 */ |
|
152 void CancelPlaNotification(); |
|
153 |
|
154 /** |
|
155 * Handle a physical link event. |
|
156 * |
|
157 * @since Symbian^4 |
|
158 * @param aResult The status code of the event. |
|
159 */ |
|
160 void HandlePhysicalLinkResultL( TInt aResult ); |
|
161 |
|
162 private: |
|
163 |
|
164 /** |
|
165 * Package buffer for retrieving physical link events. |
|
166 */ |
|
167 TBTBasebandEvent iBbEvent; |
|
168 |
|
169 /** |
|
170 * Subsession with the socket server for |
|
171 * getting physical link event notifications. |
|
172 */ |
|
173 RBTPhysicalLinkAdapter iPla; |
|
174 |
|
175 /** |
|
176 * iPairingOkTimer is activated if the link goes down. |
|
177 * If it expires it means the pairing process has failed, |
|
178 * then the error popup will be shown. |
|
179 * If the pairing process ends correctly, DoHandleRegistryNewPairedEvent |
|
180 * will be called and it will cancel the timer. |
|
181 * iActivePairingOk is the active object associated to the timer. |
|
182 */ |
|
183 RTimer iPairingOkTimer; |
|
184 CBtSimpleActive* iActivePairingOk; |
|
185 TBool iUserAwarePairing; |
|
186 }; |
|
187 |
|
188 #endif /*BTNOTIFINCOMINGPAIRINGHANDLER_H*/ |
|
189 |
|
190 |
|
191 |
|