|
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: |
|
15 * Implementations of SDP queries |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef BASRVSDPQUERY_H |
|
21 #define BASRVSDPQUERY_H |
|
22 |
|
23 #include <e32base.h> |
|
24 #include <btsdp.h> |
|
25 #include <bt_sock.h> |
|
26 #include <btmanclient.h> |
|
27 #include "BTAccInfo.h" |
|
28 #include "basrvactive.h" |
|
29 |
|
30 class TBTDevAddr; |
|
31 class CSdpSearchPattern; |
|
32 |
|
33 |
|
34 class TBTSdpAttrInt |
|
35 { |
|
36 public: |
|
37 TUUID iUUID; // The UUID of the service. Must be specified by caller. |
|
38 TUint16 iAttrID; // The Attribute ID. Must be specified by the caller. |
|
39 TUint iAttrValue; // The value of the attribute if this is found in the device. |
|
40 }; |
|
41 |
|
42 class MBasrvSdpQuerier |
|
43 { |
|
44 public: |
|
45 |
|
46 /** |
|
47 * Indicates GetAccInfo completed. |
|
48 * @param aAcc the accinfo if the operation succeeded. |
|
49 * @param aErr the completion status |
|
50 */ |
|
51 virtual void GetAccInfoCompletedL(TInt aErr, const TAccInfo* aAcc, const TBTDeviceClass* aCod) = 0; |
|
52 |
|
53 }; |
|
54 |
|
55 /** |
|
56 * The base class for various SDP query strategies |
|
57 */ |
|
58 class CBasrvSdpQuery : public CBase, public MSdpAgentNotifier, public MBasrvActiveObserver, |
|
59 public MSdpAttributeValueVisitor |
|
60 { |
|
61 public: |
|
62 |
|
63 static CBasrvSdpQuery* NewL(MBasrvSdpQuerier& aQuerier); |
|
64 |
|
65 ~CBasrvSdpQuery(); |
|
66 |
|
67 void QueryAccInfoL(const TBTDevAddr& aDevAddr, TBool aTolerateSdpError); |
|
68 |
|
69 private: // From MSdpAgentNotifier |
|
70 |
|
71 /** |
|
72 * Called when an service record request operation completes. |
|
73 * |
|
74 * @param aError KErrNone if successful; |
|
75 * KErrEof if there are no more SDP records left to be read; or an SDP error. |
|
76 * @param aHandle Service record for which the query was made |
|
77 * @param aTotalRecordsCount Total number of matching records |
|
78 */ |
|
79 void NextRecordRequestComplete( |
|
80 TInt aError, |
|
81 TSdpServRecordHandle aHandle, |
|
82 TInt aTotalRecordsCount); |
|
83 |
|
84 /** |
|
85 * Called when an attribute request (CSdpAgent::AttributeRequestL()) wants to |
|
86 * pass up a result. |
|
87 * |
|
88 * @param aHandle Service record for which the query was made |
|
89 * @param aAttrID ID of the attribute obtained |
|
90 * @param aAttrValue Attribute value obtained |
|
91 */ |
|
92 void AttributeRequestResult( |
|
93 TSdpServRecordHandle aHandle, |
|
94 TSdpAttributeID aAttrID, |
|
95 CSdpAttrValue* aAttrValue); |
|
96 |
|
97 /** |
|
98 * Called when an attribute request (CSdpAgent::AttributeRequestL()) wants to |
|
99 * signal the completion of a attribute request. |
|
100 * |
|
101 * @param aHandle Service record for which the query was made |
|
102 * @param aError an error |
|
103 */ |
|
104 void AttributeRequestComplete(TSdpServRecordHandle aHandle, TInt aError); |
|
105 // from base class MSdpAttributeValueVisitor |
|
106 |
|
107 /** |
|
108 * From MSdpAttributeValueVisitor. |
|
109 * Called to pass an attribute value. |
|
110 * |
|
111 * @since S60 v3.2 |
|
112 * @param ?arg1 ?description |
|
113 */ |
|
114 void VisitAttributeValueL( CSdpAttrValue &aValue, TSdpElementType aType ); |
|
115 |
|
116 /** |
|
117 * From MSdpAttributeValueVisitor. |
|
118 * Called to indicate the start of a list of attribute values. |
|
119 * This call is followed by a call to VisitAttributeValueL() |
|
120 * for each attribute value in the list, and concluded by |
|
121 * a call to EndList(). |
|
122 * |
|
123 * @since S60 v3.2 |
|
124 * @param ?arg1 ?description |
|
125 */ |
|
126 void StartListL( CSdpAttrValueList &aList ); |
|
127 |
|
128 /** |
|
129 * From MSdpAttributeValueVisitor. |
|
130 * Called to indicate the end of a list of attribute values. |
|
131 * |
|
132 * @since S60 v3.2 |
|
133 * @param ?arg1 ?description |
|
134 */ |
|
135 void EndListL(); |
|
136 |
|
137 private: |
|
138 // From MBasrvActiveObserver |
|
139 |
|
140 void RequestCompletedL(CBasrvActive& aActive); |
|
141 |
|
142 void CancelRequest(CBasrvActive& aActive); |
|
143 |
|
144 |
|
145 private: |
|
146 |
|
147 void ConstructL(); |
|
148 |
|
149 CBasrvSdpQuery(MBasrvSdpQuerier& aQuerier); |
|
150 |
|
151 void QueryCompleteL(TInt aStatus); |
|
152 |
|
153 void DoNextServiceRecordRequestL(); |
|
154 |
|
155 void NextRecordRequestCompleteL( |
|
156 TInt aError, |
|
157 TSdpServRecordHandle aHandle, |
|
158 TInt aTotalRecordsCount); |
|
159 |
|
160 void AttributeRequestResultL( |
|
161 TSdpServRecordHandle aHandle, |
|
162 TSdpAttributeID aAttrID, |
|
163 CSdpAttrValue* aAttrValue); |
|
164 |
|
165 void AttributeRequestCompleteL(TSdpServRecordHandle aHandle, TInt aError); |
|
166 |
|
167 void MakeAccInfo(TAccInfo& aInfo); |
|
168 |
|
169 private: |
|
170 |
|
171 MBasrvSdpQuerier& iQuerier; // not own |
|
172 |
|
173 CSdpAgent* iSdpAgent; |
|
174 CSdpSearchPattern* iSdpSearchPattern; |
|
175 RArray<TBTSdpAttrInt> iServiceAttrs; |
|
176 |
|
177 TInt iCursor; |
|
178 TBTDevAddr iAddr; |
|
179 |
|
180 CBasrvActive* iActive; |
|
181 RBTRegServ iRegServ; |
|
182 RBTRegistry iReg; |
|
183 CBTRegistryResponse* iResponse; |
|
184 TBool iTolerateSdpError; |
|
185 }; |
|
186 #endif // BASRVSDPQUERY_H |
|
187 |
|
188 |