|
1 /* |
|
2 * Copyright (c) 2006 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: Helper class for performing pairing (i.e. bonding) |
|
15 * with another device. |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef BTENGOTGPAIR_H_ |
|
20 #define BTENGOTGPAIR_H_ |
|
21 |
|
22 #include <bttypes.h> |
|
23 #include <bluetooth/pairing.h> |
|
24 #include <e32property.h> |
|
25 #include "btengpairbase.h" |
|
26 #include "btengprivatepskeys.h" |
|
27 |
|
28 /** |
|
29 * Perform a outgoing pair with a BT device. |
|
30 * |
|
31 * @lib ?library |
|
32 * @since S60 v5.1 |
|
33 */ |
|
34 NONSHARABLE_CLASS( CBTEngOtgPair ) : public CBTEngPairBase |
|
35 { |
|
36 |
|
37 public: |
|
38 |
|
39 /** |
|
40 * Two-phase constructor |
|
41 * @param aParent the owner of this object |
|
42 * @param aAddr the remote device this observer is targeted to |
|
43 */ |
|
44 static CBTEngPairBase* NewL( CBTEngPairMan& aParent, |
|
45 const TBTDevAddr& aAddr ); |
|
46 |
|
47 /** |
|
48 * Destructor |
|
49 */ |
|
50 ~CBTEngOtgPair(); |
|
51 |
|
52 private: // From CBTEngPairBase |
|
53 |
|
54 /** |
|
55 * Start observing the result of pairing which was originated from |
|
56 * the remote device. |
|
57 * @param the address of the remote device to be paired |
|
58 * @return KErrNone if this request is accepted; otherwise an error code |
|
59 */ |
|
60 TInt ObserveIncomingPair( const TBTDevAddr& aAddr ); |
|
61 |
|
62 /** |
|
63 * Start an outgoing pairing with the remote device. |
|
64 * @param the address of the remote device to be paired |
|
65 * @return KErrNone if this request is accepted; otherwise an error code |
|
66 */ |
|
67 void HandleOutgoingPairL( const TBTDevAddr& aAddr, TUint aCod ); |
|
68 |
|
69 /** |
|
70 * Cancel any outstanding pairing operation. |
|
71 */ |
|
72 void CancelOutgoingPair(); |
|
73 |
|
74 /** |
|
75 * Cancels pairing handling with the specified device |
|
76 * @param aAddr the address of the device the pairing is with |
|
77 */ |
|
78 void StopPairHandling( const TBTDevAddr& aAddr ); |
|
79 |
|
80 /** |
|
81 * Handle a pairing result with the remote device which this is for. |
|
82 * Must be specialized by subclass. |
|
83 * |
|
84 * @param aResult The status code of the pairing or authentication result. |
|
85 */ |
|
86 void DoHandlePairServerResult( TInt aResult ); |
|
87 |
|
88 /** |
|
89 * Handles registry new paired event for the remote |
|
90 * device this is pairing with. |
|
91 * @aType the type of authentication with the device. |
|
92 */ |
|
93 void DoHandleRegistryNewPairedEvent( const TBTNamelessDevice& aDev ); |
|
94 |
|
95 private: // from base class MBTEngActiveObserver |
|
96 |
|
97 /** |
|
98 * From MBTEngActiveObserver. |
|
99 * Callback to notify that an outstanding request has completed. |
|
100 * |
|
101 * @since S60 v5.1 |
|
102 * @param aActive Pointer to the active object that completed. |
|
103 * @param aId The ID that identifies the outstanding request. |
|
104 * @param aStatus The status of the completed request. |
|
105 */ |
|
106 void RequestCompletedL( CBTEngActive* aActive, TInt aId, TInt aStatus ); |
|
107 |
|
108 /** |
|
109 * From MBTEngActiveObserver. |
|
110 * Callback to notify that an error has occurred in RunL. |
|
111 * |
|
112 * @since S60 v5.1 |
|
113 * @param aActive Pointer to the active object that completed. |
|
114 * @param aId The ID that identifies the outstanding request. |
|
115 * @param aStatus The status of the completed request. |
|
116 */ |
|
117 void HandleError( CBTEngActive* aActive, TInt aId, TInt aError ); |
|
118 |
|
119 private: |
|
120 |
|
121 /** |
|
122 * C++ default constructor |
|
123 */ |
|
124 CBTEngOtgPair( CBTEngPairMan& aParent, const TBTDevAddr& aAddr ); |
|
125 |
|
126 /** |
|
127 * Symbian 2nd-phase constructor |
|
128 */ |
|
129 void ConstructL(); |
|
130 |
|
131 /** |
|
132 * Starts an actual pair operation. |
|
133 */ |
|
134 void DoPairingL(); |
|
135 |
|
136 /** |
|
137 * Cancel any outstanding pairing operation. |
|
138 */ |
|
139 void DoCancelOutgoingPair(); |
|
140 |
|
141 private: // data |
|
142 |
|
143 /** |
|
144 * Socket address of the remote device to pair with. |
|
145 */ |
|
146 TBTSockAddr iSockAddr; |
|
147 |
|
148 /** |
|
149 * The CoD of the device to be paired |
|
150 */ |
|
151 TUint32 iCod; |
|
152 |
|
153 /** |
|
154 * Dedicated bonding session to the pairing server. |
|
155 */ |
|
156 RBluetoothDedicatedBondingInitiator iBondingSession; |
|
157 |
|
158 /** |
|
159 * socket for creating L2CAP link with the remote device. |
|
160 */ |
|
161 RSocket iSocket; |
|
162 |
|
163 /** |
|
164 * Timer for recovery from Repeated Attempts |
|
165 */ |
|
166 RTimer iTimer; |
|
167 |
|
168 /** |
|
169 * used for getting and setting outgoing pair state |
|
170 */ |
|
171 RProperty iOutgoProperty; |
|
172 |
|
173 /** |
|
174 * the current pairing mode this class is in |
|
175 */ |
|
176 TBTOutgoingPairMode iPairMode; |
|
177 |
|
178 }; |
|
179 |
|
180 |
|
181 #endif // BTENGOTGPAIR_H_ |