1 /* |
|
2 * Copyright (c) 2004-2007 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: Contains the CBtDiscover class definition. Bluetooth device discovery and SDP. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CBTDISCOVER_H |
|
20 #define CBTDISCOVER_H |
|
21 |
|
22 #include <btextnotifiers.h> |
|
23 #include <btmanclient.h> |
|
24 #include <obex.h> |
|
25 #include <btsdp.h> |
|
26 |
|
27 #include "e32base.h" |
|
28 #include "tprinter.h" |
|
29 #include "btprotocolconsts.h" |
|
30 |
|
31 /** |
|
32 * \brief Implements Bluetooth device discovery and SDP. |
|
33 * |
|
34 * Implements Bluetooth device discovery and Service Discovery Protocol (SDP). |
|
35 * Uses the low-level Symbian interfaces for doing a Bluetooth device discovery, |
|
36 * allowing for more flexibility with the user interface. Results of the device discovery and |
|
37 * SDP request are stored in private variables until extracted by CRsBTDiscoverEngine |
|
38 * which owns the only instance of this class, and directs the asynchronous functionality. |
|
39 * \sa CRsBtDiscoverEngine |
|
40 */ |
|
41 NONSHARABLE_CLASS(CBtDiscover) : public CBase, public MSdpAgentNotifier |
|
42 { |
|
43 public: |
|
44 |
|
45 static CBtDiscover* NewL(); |
|
46 |
|
47 virtual ~CBtDiscover(); |
|
48 |
|
49 void Start(TRequestStatus& aStatus); |
|
50 void Stop(); |
|
51 void Reset(); |
|
52 |
|
53 TBool IsDoingSDP() const; |
|
54 TBool IsFindingDevices() const; |
|
55 TBool IsBPPSupported() const; |
|
56 TBool IsOPPSupported() const; |
|
57 |
|
58 void StopSDP(); |
|
59 |
|
60 void GetNextDevice(TRequestStatus &aStatus); |
|
61 void GetSupportedServicesL(TRequestStatus &aStatus, TUint32 aServiceMask = -1); |
|
62 |
|
63 TBool SupportsContentType(const TDesC &aContType) const; |
|
64 void SetContentTypesL(const TPtrC8 &aString); |
|
65 |
|
66 void SetPrinterModelL(const TPtrC8 &aString); |
|
67 const TDesC& GetPrinterModel() const; |
|
68 |
|
69 void SetNameRecord(TNameRecord aNameRecord); |
|
70 TNameRecord GetNameRecord() const; |
|
71 |
|
72 const TDesC& GetDeviceName() const; |
|
73 TBTDeviceClass GetDeviceClass() const; |
|
74 |
|
75 TInt GetBPPPort() const; |
|
76 void SetBPPPort(TInt aPort); |
|
77 TInt GetSTSPort() const; |
|
78 void SetSTSPort(TInt aPort); |
|
79 TInt GetOPPPort() const; |
|
80 void SetOPPPort(TInt aPort); |
|
81 |
|
82 void SetVendor( TPrinter::TPrinterVendor aVendor ); |
|
83 TPrinter::TPrinterVendor GetVendor() const; |
|
84 |
|
85 public: // From MSdpAgentNotifier |
|
86 |
|
87 void AttributeRequestComplete(TSdpServRecordHandle aHandle, TInt aError); |
|
88 void NextRecordRequestComplete(TInt aError, TSdpServRecordHandle aHandle, TInt aTotalRecordsCount); |
|
89 void AttributeRequestResult(TSdpServRecordHandle aHandle, TSdpAttributeID aAttrID, CSdpAttrValue* aAttrValue); |
|
90 |
|
91 private: |
|
92 CBtDiscover(); |
|
93 void ConstructL(); |
|
94 |
|
95 void StartSDPL(); |
|
96 void AttributeRequestResultL( TSdpAttributeID aAttrID, CSdpAttrValue* aValue ); |
|
97 void GetNextAttributeL(TSdpServRecordHandle aHandle); |
|
98 |
|
99 public: |
|
100 TSdpAttributeID iCurrentSDPAttrID; |
|
101 TUint iCurrentServiceUUID; |
|
102 TBool iFoundSTS; |
|
103 TBool iWantedService; |
|
104 |
|
105 private: |
|
106 // internal flags |
|
107 // operation flags |
|
108 TBool iDoingSDP; |
|
109 TBool iFindingDevices; |
|
110 |
|
111 CSdpAgent* iAgent; |
|
112 |
|
113 TRequestStatus *iRequestStatus; |
|
114 |
|
115 CSdpSearchPattern* iSdpSearchPattern; |
|
116 CSdpAttrIdMatchList* iMatchList; |
|
117 |
|
118 HBufC* iContentTypes; |
|
119 |
|
120 RSocketServ iSocketServ; |
|
121 RHostResolver iHostResolver; |
|
122 |
|
123 // device data |
|
124 TNameEntry iNameEntry; |
|
125 TInquirySockAddr iSockAddr; |
|
126 HBufC* iPrinterModel; |
|
127 TPrinter::TPrinterVendor iVendor; |
|
128 TInt iBPPPort; |
|
129 TInt iSTSPort; |
|
130 TInt iOPPPort; |
|
131 }; |
|
132 |
|
133 |
|
134 /** |
|
135 * \brief Enumerate the values in a SDP response attribute list. |
|
136 * |
|
137 * Used to parse attributes from the structured data returned by a Bluetooth |
|
138 * Service Discovery Protocol request. |
|
139 */ |
|
140 class CBTAttribValVisitor : public CBase, public MSdpAttributeValueVisitor |
|
141 { |
|
142 public: |
|
143 static CBTAttribValVisitor* NewLC( CBtDiscover& aDiscover ); |
|
144 ~CBTAttribValVisitor(); |
|
145 |
|
146 public: // from MSdpAttributeValueVisitor |
|
147 void VisitAttributeValueL(CSdpAttrValue& aValue, TSdpElementType aType); |
|
148 void StartListL(CSdpAttrValueList& aList); |
|
149 void EndListL(); |
|
150 |
|
151 private: |
|
152 CBTAttribValVisitor( CBtDiscover& aDiscover ); |
|
153 void CheckUuid( const TUUID& aUuid ); |
|
154 void CheckUint( const TUint& aValue ); |
|
155 void CheckVendor( const TDesC8& aVendor ); |
|
156 |
|
157 private: |
|
158 CBtDiscover& iDiscover; |
|
159 }; |
|
160 |
|
161 #endif // CBTDISCOVER_H |
|
162 |
|
163 // End of File |
|