56
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 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: Incoming Pairing handler definition
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef BTENGINCPAIR_H_
|
|
20 |
#define BTENGINCPAIR_H_
|
|
21 |
|
|
22 |
#include <bt_sock.h>
|
|
23 |
#include "btengpairbase.h"
|
|
24 |
|
|
25 |
/**
|
|
26 |
* Class CBTEngIncPair
|
|
27 |
*
|
|
28 |
* Handles an incoming pairing.
|
|
29 |
*
|
|
30 |
* @since S60 S60 v5.1
|
|
31 |
*/
|
|
32 |
NONSHARABLE_CLASS( CBTEngIncPair ) : public CBTEngPairBase
|
|
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 CBTEngIncPair* NewL( CBTEngPairMan& aParent,
|
|
42 |
const TBTDevAddr& aAddr);
|
|
43 |
|
|
44 |
/**
|
|
45 |
* Destructor
|
|
46 |
*/
|
|
47 |
~CBTEngIncPair();
|
|
48 |
|
|
49 |
|
|
50 |
private: // From CBTEngPairBase
|
|
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 MBTEngActiveObserver
|
|
89 |
|
|
90 |
/**
|
|
91 |
* From MBTEngActiveObserver.
|
|
92 |
* Callback to notify that an outstanding request has completed.
|
|
93 |
*
|
|
94 |
* @since S60 v5.1
|
|
95 |
* @param aActive Pointer to the active object that completed.
|
|
96 |
* @param aId The ID that identifies the outstanding request.
|
|
97 |
* @param aStatus The status of the completed request.
|
|
98 |
*/
|
|
99 |
virtual void RequestCompletedL( CBTEngActive* aActive, TInt aId, TInt aStatus );
|
|
100 |
|
|
101 |
/**
|
|
102 |
* From MBTEngActiveObserver.
|
|
103 |
* Callback to notify that an error has occurred in RunL.
|
|
104 |
*
|
|
105 |
* @since S60 v5.1
|
|
106 |
* @param aActive Pointer to the active object that completed.
|
|
107 |
* @param aId The ID that identifies the outstanding request.
|
|
108 |
* @param aStatus The status of the completed request.
|
|
109 |
*/
|
|
110 |
virtual void HandleError( CBTEngActive* aActive, TInt aId, TInt aError );
|
|
111 |
|
|
112 |
private:
|
|
113 |
|
|
114 |
/**
|
|
115 |
* C++ default constructor
|
|
116 |
*/
|
|
117 |
CBTEngIncPair(CBTEngPairMan& aParent, const TBTDevAddr& aAddr);
|
|
118 |
|
|
119 |
/**
|
|
120 |
* 2nd phase constructor.
|
|
121 |
*/
|
|
122 |
void ConstructL();
|
|
123 |
|
|
124 |
/**
|
|
125 |
* Start monitoring physical link events if it hasn't yet.
|
|
126 |
*
|
|
127 |
* @since S60 v5.1
|
|
128 |
*
|
|
129 |
*/
|
|
130 |
void MonitorPhysicalLink();
|
|
131 |
|
|
132 |
/**
|
|
133 |
* Opens physical link adaptor with the device.
|
|
134 |
*
|
|
135 |
* @since S60 v5.1
|
|
136 |
* @return KErrNone if the physical link exists.
|
|
137 |
*
|
|
138 |
*/
|
|
139 |
TInt OpenPhysicalLinkAdaptor();
|
|
140 |
|
|
141 |
/**
|
|
142 |
* Cancel all outstanding requests.
|
|
143 |
*
|
|
144 |
* @since S60 v5.1
|
|
145 |
*/
|
|
146 |
void CancelPlaNotification();
|
|
147 |
|
|
148 |
/**
|
|
149 |
* Handle a physical link event.
|
|
150 |
*
|
|
151 |
* @since S60 v5.1
|
|
152 |
* @param aResult The status code of the event.
|
|
153 |
*/
|
|
154 |
void HandlePhysicalLinkResultL( TInt aResult );
|
|
155 |
|
|
156 |
private:
|
|
157 |
|
|
158 |
/**
|
|
159 |
* Package buffer for retrieving physical link events.
|
|
160 |
*/
|
|
161 |
TBTBasebandEvent iBbEvent;
|
|
162 |
|
|
163 |
/**
|
|
164 |
* Subsession with the socket server for
|
|
165 |
* getting physical link event notifications.
|
|
166 |
*/
|
|
167 |
RBTPhysicalLinkAdapter iPla;
|
|
168 |
|
|
169 |
/**
|
|
170 |
* iPairingOkTimer is activated if the link goes down.
|
|
171 |
* If it expires it means the pairing process has failed,
|
|
172 |
* then the error popup will be shown.
|
|
173 |
* If the pairing process ends correctly, DoHandleRegistryNewPairedEvent
|
|
174 |
* will be called and it will cancel the timer.
|
|
175 |
* iActivePairingOk is the active object associated to the timer.
|
|
176 |
*/
|
|
177 |
RTimer iPairingOkTimer;
|
|
178 |
CBTEngActive* iActivePairingOk;
|
|
179 |
TBool iUserAwarePairing;
|
|
180 |
};
|
|
181 |
|
|
182 |
#endif /*BTENGINCPAIR_H_*/
|